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

查看:469
本文介绍了没有可以在应用程序配置文件中找到名为“MyEntities”的连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用实体框架和ASP.NET MVC 4构建一个应用程序



我的解决方案分为两个项目;




  • 包含我的数据模型(.edmx)文件和一些自定义界面的类库

  • 引用的'container'MVC项目上面的类库



我的问题是当我尝试使用'MyEntites' DbContext 时,我得到以下错误:



应用程序配置文件中找不到名为MyEntities的连接字符串。


我猜这个问题与连接字符串位于类库的app.config而不是MVC项目有关。



有没有人有任何建议?

解决方案

尝试复制连接字符串到MVC项目中的.config文件。


I am using entity framework and ASP.NET MVC 4 to build an application

My solution is split into two projects;

  • A class library that includes my data model (.edmx) file and a few custom interfaces
  • The 'container' MVC project that references the class library above

My problem is that when I attempt to use the 'MyEntites' DbContext I get the the following error:

No connection string named 'MyEntities' could be found in the application config file.

I guess the problem has something to do with the fact that connection string lies within the app.config of the class library rather than the MVC project.

Does anyone have any suggestions?

解决方案

Try copying the connections string to the .config file in the MVC project.

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

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