How do I dynamically tell a .NET MVC application which datasource to point to?

Posted by Bialecki on Stack Overflow See other posts from Stack Overflow or by Bialecki
Published on 2010-04-13T19:04:20Z Indexed on 2010/04/13 19:22 UTC
Read the original article Hit count: 346

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about .NET