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>
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>
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!