在Web主机上定义一个连接字符串,类似于在本地计算机上的调试模式下的EF连接字符串 [英] Define a Connection String on Web Host similar to EF Connection String in Debug Mode on Local Machine

查看:113
本文介绍了在Web主机上定义一个连接字符串,类似于在本地计算机上的调试模式下的EF连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我在本地asp.net mvc网站中使用的连接字符串,我想通过虚拟主机发布该网站.他们有.\SQLEXPRESS12的SQL实例,我也创建了一个数据库名myapp_db.我也用该数据库创建了一个用户.如何修改EF生成的连接字符串,它也会影响我的自动生成的模型吗?

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.我知道这个问题可能不是StackOverflow的指南,但我将不胜感激.

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>

推荐答案

只需更改connectionString的这一部分,就像这样:

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

这篇关于在Web主机上定义一个连接字符串,类似于在本地计算机上的调试模式下的EF连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆