在应用程序配置文件中找不到名为“ MyApplicationEntities”的连接字符串

在应用程序配置文件中找不到名为“ MyApplicationEntities”的连接字符串

问题描述:

我只是安装EF 4.3,然后尝试通过迁移来升级我的项目。但是我在尝试通过Package Manager控制台对项目执行 add-migration initial 时遇到问题。

I just install EF 4.3 and trying to upgrade my project with migration. however I am getting issues with trying to execute add-migration initial to my project via Package Manager console.

现在抛出任何异常在应用程序配置文件中找不到名为 MyApplicationEntities的连接字符串。

现在我的配置已全部包含

Now my config has it all

<connectionStrings>
<add name="MyApplicationEntities" 
     connectionString="metadata=res://*/DataModel.csdl|res://*/DataModel.ssdl|res://*/DataModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=localhost;initial catalog=MyApplicationEntitiesDB;integrated security=True;multipleactiveresultsets=True;App=EntityFramework&quot;" 
     providerName="System.Data.EntityClient" />

我不确定是什么问题是它是EF 4.3中的错误,还是我做错了。

I am not sure what is the issue is it a bug in EF 4.3 or there is something I am not doing right.

我认为

I thought this post has solved the issue but not quite.

任何人都得到了答案。

Anyone got an answer.

感谢Sanj。

啊,这是偶然发现的。

Ah, figured this out accidentally.

我必须删除

public MasterEntities()
    : base("name=MyApplicationEntities")
    //      ^^^^^
{
}

public MasterEntities()
    : base("MyApplicationEntities")
{
}

EF 4.3不喜欢将连接字符串称为 name = xxxxx

EF 4.3 does not like connection string being called name=xxxxx