ASP.NET System.Data.EntityClient连接字符串帮助

前端之家收集整理的这篇文章主要介绍了ASP.NET System.Data.EntityClient连接字符串帮助前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在共享服务器上运行ASP.NET MVC,我在通过System.Data.EntityClient连接到sql时遇到问题.下面是我的软件提供商给我连接到sql的连接字符串以及VS在开发期间为我的本地机器配置的连接字符串,当我部署到服务器时,我的连接字符串应该是什么样子?

来自我的托管服务商:

<add name="WeddingsDBEntities" 
  connectionString="data Source=<server name>; Initial Catalog=<db name>; User ID=<user ID>; Password=<password>;" 
  providerName="System.Data.EntityClient"/>

来自VS(开发期间):

connectionString="Metadata=res://*/Models.WeddingsModel.csdl|res://*/Models.WeddingsModel.ssdl|res://*/Models.WeddingsModel.msl;provider=System.Data.sqlClient;provider connection string="Data Source=.\sqlEXPRESS;AttachDbFilename=|DataDirectory|\WeddingsDB.mdf;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient"

谢谢!

解决方法

您必须将连接字符串包装为实体连接字符串,格式为
<add name="Name"
  connectionString="Metadata=<Conceptual Model>|<Store Model>|<Mapping Model>;
  provider=<Underlying Connection Provider>;
  provider connection string=&quot;<Underlying ConnectionString>&quot;" 
  providerName="System.Data.EntityClient"/>

代替:

<add name="WeddingsDBEntities" 
  connectionString="data Source=<server name>; Initial Catalog=<db name>; User ID=<user ID>; Password=<password>;" 
  providerName="System.Data.EntityClient"/>

用这个:

<add name="WeddingsDBEntities"
  connectionString="Metadata=res://*/Models.WeddingsModel.csdl|res://*/Models.WeddingsModel.ssdl|res://*/Models.WeddingsModel.msl;provider=System.Data.sqlClient;provider connection string=&quot;data Source=<server name>; Initial Catalog=<db name>; User ID=<user ID>; Password=<password>;MultipleActiveResultSets=True&quot;" 
  providerName="System.Data.EntityClient"/>
原文链接:https://www.f2er.com/aspnet/250991.html

猜你在找的asp.Net相关文章