I'm in a situation where I have a single SQL Server database (call it my "logins" database) that contains records for a number of clients, most importantly what the database name is for that client. My login screen for this web app has the standard username and password fields along with a "unique ID" field too. Herein lies the problem: to try clear this up here's an example.
My database structure
Logins
(customer's unique login code and their database name here)Customer_1
Customer_2
- etc...
Requirement
Upon login, I need to verify the customer's unique code against the logins database and then somehow persist the fact that further queries for the duration of the authenticated session must run against their own database and that is where I'm stuck.
Firstly, is this even possible? I don't want to store a connection string for each possible client database - I want to work this out upon login.
Secondly, if it is possible, how would I go about doing this using Entity Framework and ASP.NET MVC4?