For my project I have to travel between the client's site and my workplace, so I have to test my code on their site's database too.
My purpose is to have 2 connection strings listed in web.config, one for my workplace, and one for the client's site. Remote connection is not possible due to security issues.
How do I modify which connection string my model is using?
How do I modify which connection string a model uses?
Create two connection string entries in the application configuration file, e.g.:
Then create the contexts in the following way:
Code: Select all
Code: Select all
using(MyEntities db = new MyEntities("name=ConnString")) {
//...
}
using(MyEntities db_client = new MyEntities ("name=ConnString_Client")) {
//...
}