简体   繁体   English

来自ASP.NET MVC4中Web.config文件的连接字符串错误

[英]Connection Strings error from the Web.config File in asp.net mvc4

i deployed the project through visual studio to a website hosting that support mvc and MS sql too after that i edit the config.web with the connection string provided by database hosting and restore a database backup successfully but there's some error in web.config file so the website didn't work properly related to database access but it works fine locally 我也通过Visual Studio将项目部署到了​​支持mvc和MS sql的网站托管中,之后我也使用数据库托管提供的连接字符串编辑config.web并成功还原了数据库备份,但是web.config文件中存在一些错误,因此该网站无法正常运行,与数据库访问相关,但在本地运行良好

this is a connection string from web,config file ( which works locally without errors) 这是来自web,config文件的连接字符串(可在本地正常运行而不会出错)

<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-wa3iny_pro_mvc-20140520172729;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-wa3iny_pro_mvc-20140520172729.mdf" providerName="System.Data.SqlClient" />


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

and honestly this is a first time for me to deal with things related to deploy and publish project through website hosting so that i tried many things to correct the error related to connection string but i couldn't do that 老实说,这是我第一次通过网站托管来处理与部署和发布项目有关的事情,因此我尝试了很多方法来纠正与连接字符串有关的错误,但我无法做到这一点

this is a connection string from website hosting server ,config file 这是来自网站托管服务器配置文件的连接字符串

<add name="DefaultConnection" connectionString="Data Source=SQL5004.myASP.NET;Initial Catalog=DB_9B2DF3_wa3iny;User Id=YOUR_DB_name;Password=YOUR_DB_PASSWORD;" providerName="System.Data.EntityClient" />

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

but there's some error here in first i didn't include the second connection string connection wa3enyEntities 但首先出现一些错误,我没有包含第二个连接字符串连接wa3enyEntities

but the website hosting support told me that there's error ("No connection string named 'wa3enyEntities' could be found in the application config file.) so that i included it but the error still existed 但是网站托管支持告诉我,有一个错误(“在应用程序配置文件中找不到名为'wa3enyEntities'的连接字符串。)因此我将其包括在内,但该错误仍然存​​在

You have not updated your wa3enyEntities connection string. 您尚未更新wa3enyEntities连接字符串。 If you look at it carefully, you will see "provider connection string:..." which is still pointing to the default sql server instance. 如果仔细看,您会看到“ provider connection string:...”,它仍然指向默认的sql server实例。

i used this coonection string and he work without any errors 我使用了这个字符串,他工作时没有任何错误

http://pastie.org/9526738 http://pastie.org/9526738

thanks @parth shah for your help 感谢@parth shah的帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM