ASP.NET MVC 4,代码优先,MySQL
无法检索"MvcStore.Models.Customer"的元数据.不支持使用相同的DbCompiledModel来针对不同类型的数据库服务器创建上下文.而是为每种使用的服务器类型创建一个单独的DbCompiledModel.
Unable to retrieve metadata for 'MvcStore.Models.Customer'. Using the same DbCompiledModel to create contexts against different types of database servers is not supported. Instead, create a separate DbCompiledModel for each type of server being used.
Web.config
Web.config
<connectionStrings>
<add name="StoreContext" connectionString="Server=127.0.0.1; port=3306; Database=webmvcstore; Uid=root; Pwd=root;" providerName="MySql.Data.MySqlClient" />
</connectionStrings>
上下文
public class StoreContext : DbContext
{
public DbSet<Customer> Customers { get; set; }
}
实体
public class Customer
{
public int Id { get; set; }
public string Name { get; set; }
}
DLL
Mysql.Data,Mysql.Data.Entity,Mysql.Data.Web
Mysql.Data, Mysql.Data.Entity, Mysql.Data.Web
.NET Framework 4.5
.NET Framework 4.5
Visual Studio 2012
Visual Studio 2012
我不知道该如何解决.在带有MVC 3的VS 2010中,一切正常.
I don't know how to fix this. In VS 2010 with MVC 3 everything works.
嘿!!
尝试将提供程序名称更改为providerName ="System.Data.SqlClient"
try to change the provider name to providerName="System.Data.SqlClient"