dotnet / dotnet/EntityFramework.Docs

Scaling SaaS model (one DbContext, database-per-tenant) with EF Core?

Open
#3,870 7 comments 0 reactions 0 assignees View on GitHub
area-multi-tenant new-pm
Dominant language
Mermaid
Stars
1.7k
Forks
2k
Avg merge
7d 23h
Merged PRs (30d)
16

Description

There doesn't seem to be any good guidance on how to set up and maintain a database-per-tenant model for EF Core.

- How to create/ migrate new tenant dbs programmatically?
- How to manage connection strings?
- How to select a specific tenant at runtime?

Sharding seemed to be supported in .NET 4.x but no support in .NET Core or beyond. How is EF Core used in a scalable, sustainable manner in a SaaS environment with tenant data isolation?

---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: bb29a2b6-c401-287f-2da9-1aeb3c633b41
* Version Independent ID: bb29a2b6-c401-287f-2da9-1aeb3c633b41
* Content: [Multi-tenancy - EF Core](https://docs.microsoft.com/en-US/ef/core/miscellaneous/multitenancy)
* Content Source: [entity-framework/core/miscellaneous/multitenancy.md](https://github.com/dotnet/EntityFramework.Docs/blob/main/entity-framework/core/miscellaneous/multitenancy.md)
* Product: **entity-framework**
* Technology: **entity-framework-core**
* GitHub Login: @JeremyLikness
* Microsoft Alias: **jeliknes**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.