Home > Database > Mysql Tutorial > body text

Why am I getting \'Unable to retrieve metadata\' when using Entity Framework with MySQL in MVC4 and POCO/Code First?

DDD
Release: 2024-10-30 10:22:27
Original
503 people have browsed it

Why am I getting

Unable to Retrieve Metadata

Question:

While setting up an MVC4 application with Entity Framework 4.4, MySQL, POCO/Code First, and existing tables in the database, encounters the error "Unable to retrieve metadata for BTD.Data.Product."

Answer:

MVC4 Controller scaffolding may not recognize the MySQL Connection String. To generate EF CRUD code for Controllers with MySQL, change the connection string in web.config as follows:

<code class="xml"><add name="BTDContext" connectionString="Data Source=host_name;Database=database_name;uid=user_id;pwd=password;" providerName="System.Data.SqlClient" /></code>
Copy after login

After generating the code, revert the connection string to:

<code class="xml"><add name="BTDContext" connectionString="Data Source=host_name;Database=database_name;uid=user_id;pwd=password;" providerName="MySql.Data.MySqlClient" /></code>
Copy after login

Ensure the provider name is correct for each scenario.

The above is the detailed content of Why am I getting \'Unable to retrieve metadata\' when using Entity Framework with MySQL in MVC4 and POCO/Code First?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!