有没有办法先改变数据库中的连接字符串? [英] Is there a way to change connection string in database first?

查看:144
本文介绍了有没有办法先改变数据库中的连接字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个数据库,它们的模式是一样的。当我使用database-first时,在创建edmx文件时指定连接字符串。我想知道,有没有办法改变连接字符串?这是,所以我可以选择要运行哪个数据库。
Thx提前!

解决方案

更改web.config文件中的连接字符串。

 < connectionStrings> 
< add name =SandBoxEntitiesconnectionString =metadata = r ... />
< / connectionStrings>

我缩写了实际的连接字符串,因为它不重要 - 只是想给你一个在web.config文件中寻找什么的想法。



您还可以以编程方式更改连接字符串。查看示例16.2。以编程方式修改EntityConnectionString


I have several databases, the schema of them are same. When I use database-first, the connection string is specified when I create the edmx file. I want to know, is there a way to change the connection string? This is, so I can choose which database to operate. Thx in advance!

解决方案

Change the connection string in the web.config file.

  <connectionStrings>
    <add name="SandBoxEntities" connectionString="metadata=r... />
  </connectionStrings>

I abbreviated the actual connection string because it isn't important -- just wanted to give you an idea of what to look for in the web.config file.

You can also change your connection strings programatically. Check out Example 16.2. Programmatically modifying an EntityConnectionString.

这篇关于有没有办法先改变数据库中的连接字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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