问题描述
我有几个数据库,它们的模式是一样的。当我使用database-first时,在创建edmx文件时指定连接字符串。我想知道,有没有办法改变连接字符串?这是,所以我可以选择要运行哪个数据库。Thx提前!
更改web.config文件中的连接字符串。
< connectionStrings>
< add name =SandBoxEntitiesconnectionString =metadata = r ... />
< / connectionStrings>
我缩写了实际的连接字符串,因为它不重要 - 只是想给你一个在web.config文件中寻找什么的想法。
您还可以以编程方式更改连接字符串。查看。
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.
这篇关于有没有办法先改变数据库中的连接字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!