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

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

问题描述

我使用实体框架和ASP.NET MVC 4来构建应用程序

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

我的解决办法是分成两个项目;

My solution is split into two projects;


  • 一个类库,其中包括我的数据模型(的.edmx)文件和一些自定义的接口

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

我的问题是,当我尝试使用My​​Entites的DbContext我得到了以下错误

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.

我想这个问题牵扯到与该连接字符串位于类库,而不是MVC项目的app.config中的事实。

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?

推荐答案

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

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

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

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