问题
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="data source=.\SQLEXPRESS;initial catalog=myapp_db;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" 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""
... />
来源:https://stackoverflow.com/questions/33145571/define-a-connection-string-on-web-host-similar-to-ef-connection-string-in-debug