Asp.net mvc 连接字符串EF代码优先

Asp.net mvc 连接字符串EF代码优先,asp.net-mvc,entity-framework,asp.net-mvc-4,entity-framework-5,Asp.net Mvc,Entity Framework,Asp.net Mvc 4,Entity Framework 5,我首先使用实体框架代码启动了一个应用程序。 在my Web.config中,我添加了连接字符串: <add name="MyContext" connectionString="Data Source=server\mssqlserver2008;Initial Catalog=dbname;persist security info=True; Integrated Security=SSPI" providerName="System.Data.SqlClient" /> 为什

我首先使用实体框架代码启动了一个应用程序。 在my Web.config中,我添加了连接字符串:

<add name="MyContext" connectionString="Data Source=server\mssqlserver2008;Initial Catalog=dbname;persist security info=True; Integrated Security=SSPI" providerName="System.Data.SqlClient" />

为什么ConnectionString是错误的???

在EF初始化代码中,请确保按如下方式指定连接字符串名称

public class MyDbContext : DbContext
{
    public MyDbContext() : base("MyContext") {}
}

在EF初始化代码中,确保指定如下连接字符串名称

public class MyDbContext : DbContext
{
    public MyDbContext() : base("MyContext") {}
}
看一看问题看一看问题