在应用程序配置文件中找不到名为“ MyApplicationEntities”的连接字符串 [英] No connection string named 'MyApplicationEntities' could be found in the application config file

查看:86
本文介绍了在应用程序配置文件中找不到名为“ 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

这篇关于在应用程序配置文件中找不到名为“ MyApplicationEntities”的连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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