asp.net Identity 2.0 How to change connection string / DbContext at runtime? -


I would like to do the following in my MVC5, ASP.NET identity 2.0 app:

  1. < P> Change the connection string used by ApplicationDBContext at runtime I have multiple clients, each with its own SQL database. So when the session starts, I need to specify the desired database connection.

  2. I agree to the class applicationDebentex that I add surcharges:

      create public static ApplicationDbContext (string connection string) {new ApplicationDbContext (connectionString Return; }  
  3. I also think that in Startup.Auth.cs I need to modify this line to pass in the string. If so, then I have problems.

Am I going down the right road? Am I missing something else? I'm basically stuck at this point to help you TIA.

You can change ApplicationDbContext to create an ApplicationDbContext instance with the appropriate connection string. Basically create an ApplicationDbContext factory method.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -