2

I am working on a multi-tenant asp.net core web api. I am using asp.net core identity and identity server 4. I also have a database for each tenant and the idea is to have Identity related tables ( e.g aspnetusers, aspnetroles etc) in the tenant databases.

When a user sends a sign-in request, I use a shared database to look up tenant for that user and then I need to select the tenant database to validate username and password (Using SignInManager)

The problem is I do not know the connection string during Startup.ConfigureServices method.

I am hoping that there is a way to modify connection string much later in the request life cycle ( once I have determined the connection string ) and then have UserStore use that DbContext instead.

Any ideas?

  • Have a look at https://stackoverflow.com/questions/36816215/dynamically-change-connection-string-in-asp-net-core - I don't see any difference between regular `DbCntext` and `Identity` based one. – Dmitry Pavlov Sep 15 '18 at 19:42

0 Answers0