I have website1 and webiste2 that runs against MyDatabase.
In MyDatabase I have some tables: dbo.Users, dbo1.Posts, dbo2.Posts. There is a foreign key relation ship between dbo.Users and dbo1.Posts, and dbo.Users and dbo2.Posts.
I want website1 and website2 to run the same code base, is it possible to have website one get it’s Posts from dbo1.Posts, while website2 gets their posts from dbo2.Posts?
The thought is that the desired schema (dbo1 or dbo2) would come from a configuration file.
In my situation, the information in dbo1.Posts and dbo2.Posts could be considered confidential. There may be users that might have access to both, or there might be users that have access to one. So as I see it there are two approaches, separate the databases physically, or logically. My Task at hand is to investigate if it can be done logically or not
Okay so here is what ended up happening. Still not sure if it’s the best solution, but if anybody comes looking for the answer to this question I did figure out a way to make it work.
With that said I still agree with Matt, and Hacked that there should be a simpler way to do this.
There are three diffrent pices to my puzzel.
First there was a map for the entity to table in question where I used the following:
Second I had a line in a Configuration helper that read from the AppSettings in the Web.config file
Third in the web.config file I had added an Appsettings as follows:
After building the app and running it I get the posts from dbo1.Posts. I can then switch the string in the web.config file to “dbo2”, refresh the page and see the posts from dbo2.Posts.