I'm developing a web application in asp.net mvc. My application uses multiple databases. The database on which working on depends by the logged user. I manage login on two levels:
- Level1 on a "master" database where I have info about the login username/email and the "specific" database to use.
- Level2 on the "specific" database where I manage users and roles with Identity2.
Example: In the "master" database I have a record in User table with: - username = user1 - databaseToUse = "specificDb1"
In the "specific" database called specificDb1, for the same user, I have a record in User table with all I need to manage user authentication and more.
What I want to achieve is:
- Start the website, click on login, insert username and password, click on login.
- Search for the username in the master database, if exist get the specific database name associated to the user.
- Set here, DYNAMICALLY, the connection string for the "specific" database and perform Identity 2 login operations.
No problems for points 1 and 2. The problem is in point 3. I use EntityFramework 6 Code First for both (master and specific) databases.
Regarding the configuration part of Identity I see in Startup.Auth.cs:
app.CreatePerOwinContext(ApplicationDbContext.Create);
app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);
Should I change something in Identity configuration?
Thanks in advance.