I have an ASP.NET Core 2.2 project using EF Core that is used by multiple customers. Each customer has their own database with the exact same schema managed by IRepository (Dynamically loaded DBsets). It is multi sub-domain projects, I would like to login uses on account.example.com, after authenticate users will redirected to websites B site.example.com authorize by Cookie Authentication.
Website A, at www.example.com
Website B, at site.example.com -(My application)
Website C, at account.example.com -(ASP.NET Identity -.Net Core 2.2)
public MydbContext(string dbName)
{
this.Database.GetDbConnection().ChangeDatabase(dbName);
}
But it got default connection string that was added in ConfigureServices in startup.cs class. How can I use Session to store connection string of current user from Cookie in HttpContext.User and change connection string of DBContext per query.