How do I dynamically tell a .NET MVC application which datasource to point to?
- by Bialecki
I'm beginning a port of an existing ColdFusion application to .NET MVC and one of the first issues I'm running into is that in ColdFusion we use the fact that you can define multiple datasources and access them in a dynamic way so that a particular user can be pointed at a particular database.
To give an example, I might have two databases, Foo and Bar which each have a table called Locations which store locations particular to that database. The databases are guaranteed to have the same tables, so that's not a concern.
In ColdFusion, you can easily dynamically point a user towards a particular datasource because it's just a string which is configured via the ColdFusion administrator (or you could programatically modify an XML file).
So the question is how to do this in .NET?
And specifically, I think I'd really like to use the Entity framework to leverage the ORM support it'll offer to perform operations on the data in the database, but I'm not sure how to do that (hopefully it's possible). Any thoughts?