ASP.NET MVC 4,代码优先,MySQL [英] ASP.NET MVC 4, Code First, MySQL

查看:86
本文介绍了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"

这篇关于ASP.NET MVC 4,代码优先,MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆