在应用程序配置文件中找不到连接字符串(但它存在) [英] No connection string could be found in the application config file (But it Does Exist)

查看:185
本文介绍了在应用程序配置文件中找不到连接字符串(但它存在)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个我发布到IIS的Web API项目,它抱怨在配置文件中没有一个特定名称的连接字符串。我验证了在我的web.config文件中有一个条目,因此它不能被拾取。我可以使用Visual Studio 2013在本地运行这个相同的web.config文件。



我很清楚引用的启动项目必须有连接字符串,那就是我的情况我验证了我的Web API项目有下面的连接字符串(我在本地机器上成功使用了相同的一个)。

 < connectionStrings> ; 
< add name =MyDBconnectionString =metadata = res://*/MyDB.csdl | res://*/MyDB.ssdl | res://*/MyDB.msl; provider = System .Data.SqlClient; provider connection string =& quot; data source = localhost\MyDB; initial catalog = MyDB; integrated security = True; MultipleActiveResultSets = True; App = EntityFramework& quot;的providerName = System.Data.EntityClient/>
< / connectionStrings>

是否在服务器上的其他地方抱怨另一个配置文件?



我已经尝试了没有运气。


内部bin只有一个web.config文件 -


您的web.config文件应该与Global.asax在同一个文件夹中, package.config,而不是bin文件夹。


I have a web API project I published to IIS and it complains there is no connection string with a specific name in my config file. I verified there is an entry in my web.config file of the web API project so it must not be picking it up. I was able to run this same web.config file locally using Visual Studio 2013.

I am well aware the referenced start up project must have the connection string and that is the case for me. I verified my web API project has the connection string below (same one I used successfully on my local machine).

<connectionStrings>
    <add name="MyDB" connectionString="metadata=res://*/MyDB.csdl|res://*/MyDB.ssdl|res://*/MyDB.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=localhost\MyDB;initial catalog=MyDB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient"/>
</connectionStrings>

Is it complaining about another config file somewhere else on the server?

I already tried the suggestions in this question with no luck.

解决方案

Inside bin there is only one web.config file -

Your web.config file should be in same folder as Global.asax, packages.config and not in bin folder.

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

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