Define a Connection String on Web Host similar to EF Connection String in Debug Mode on Local Machine

守給你的承諾、 提交于 2019-12-13 00:48:23

问题


This s the connection String I am using in my local asp.net mvc site, I want to publish the website over a web hosting. They have SQL Instance of .\SQLEXPRESS12 and I have created a database name myapp_db as well. I have created a user with that db also. How can I modify the EF generated Connection String, and will it effect my auto generated models too ?

P.S. I know this question might not be StackOverflow's guidelines, but I would appreciate any help.

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

回答1:


Just change this part of your connectionString like this:

< ... data source=Server's IP Address,Port;initial catalog=myapp_db;
      user id=username that you have created;password=yourpassword;
       MultipleActiveResultSets=True;App=EntityFramework&quot;"
       ... />


来源:https://stackoverflow.com/questions/33145571/define-a-connection-string-on-web-host-similar-to-ef-connection-string-in-debug

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!