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

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

我的问题是,当我尝试使用MyEntites"DbContext 时,出现以下错误:

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

在该目录中找不到名为MyEntities"的连接字符串应用程序配置文件.

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

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

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.

大家有什么建议吗?

推荐答案

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

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

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

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