Change database connection based on path to support multitenancy

Posted on November 19, 2019
ASP.NET Core  csharp 
Change database connection based on path to support multitenancy header image

How to change the database connection string in the DbContext of an ASP.NET Core application based on the path.

In this post I want to show an implemention of a lightweight multitenancy solution with ef core. The solution will use a database per tenant and the database connection is set up on every request based on the path. The first part of the path is the tenant id and is used as the database name.

Read More