ASP.NET System.Data.EntityClient connection string help

后端 未结 3 452
悲&欢浪女
悲&欢浪女 2020-12-11 05:11

I\'m running ASP.NET MVC on a shared server and I\'m having problems connecting to SQL via System.Data.EntityClient. Below is the connection string that my hosing provider

相关标签:
3条回答
  • 2020-12-11 05:30

    You have to wrap the connection string instide an entity connection string which is in the format of

    <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"/>
    

    Instead of:

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

    Use this:

    <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"/>
    
    0 讨论(0)
  • 2020-12-11 05:34
    <add name="Name" connectionString="metadata=res://*; provider=System.Data.SqlClient; provider connection string='; data source=YOURIP;Initial Catalog=YOURDB;Persist Security Info=True;User ID=YOURUSER;Password=YOURPASSWORD; Connect Timeout=15;Encrypt=False;Packet Size=4096;MultipleActiveResultSets=True'" 
      providerName="System.Data.EntityClient"/>
    
    Hope this Will help you!!
    
    0 讨论(0)
  • 2020-12-11 05:44

    Change the provider from entityclient to sqlclient (assume code first EF).

    providerName="System.Data.EntityClient" />

    to

    providerName="System.Data.SqlClient" />

    0 讨论(0)
提交回复
热议问题