[转]:No connection string named ‘AnyEntities’ could be found in the application config file

解决ASP.NET MVC中缺失连接字符串错误
本文解决了一个常见的ASP.NET MVC应用错误,即在配置文件中找不到指定的连接字符串。通过分析项目结构和Onion架构,指出实体框架位于基础设施项目中,而MVC项目作为启动项目未包含连接字符串。解决方案是在MVC项目的Web.config中添加所需的连接字符串。

From: http://debugmode.net/2014/09/10/no-connection-string-named-could-be-found-in-the-asp-net-mvc-application-config-file-solved/?utm_source=tuicool

While working on an ASP.NET MVC application I encountered the following error. It clearly says that some connection string is missing in the configuration file.

clip_image002

Well I have refactored the application following the onion architecture and there is nothing related to database exist in the MVC project. Project structure looks like follows:

clip_image004

The Entity Framework is part of the infrastructure project and in its App.Config file, there is an entry of connection string as follows:

clip_image006

Even though connection is present in the project which is dealing with the database, error is thrown. The reason behind this is, the MVC project is a startup project and the infrastructure project is not a startup project. We need to have connection string in the configuration file of the startup project. In this case startup project is MVC project, so to solve this error we need to copy IndiaMP connection string to Web.config of MVC project. After doing that you should not get the above error.

Solution: Copy connection string to configuration file of startup project.

Happy Coding

转载于:https://www.cnblogs.com/Blackeye286/p/4311003.html

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值