Reputation: 1560
I want to use the Ado.Net Entity Framework in an application. But the application needs to be able to connect to different databases (albeit with the exact same structure) at runtime. Further it is a client application, it's running locally.
I did not find a way to do this. There are some questions regarding accessing different databases but the answers seem to center on modifying some config files which I cannot do when the application is deployed.
Thanks in advance.
Upvotes: 0
Views: 414
Reputation: 364279
You must use different connection strings (you can pass connection string to the constructor of the context). You must somehow define these connection strings and the most common way is using configuration file. If you don't want to use configuration files user will have to specify parameters of the connection file in runtime and you will have to build correct connection strings.
There are some limitations for this scenario. Databases must be:
Upvotes: 1