Sébastien Rigaux

.NET multi-tenancy: query isolation and SQL Server partitions — part 1/4

View resource

barretblake.dev

This first installment presents a shared-schema .NET multi-tenant design: EF Core filters reads by tenant, while SQL Server physically partitions rows to speed up data access. The key distinction is that partitioning is not a security boundary; isolation relies on the EF Core global query filter.

The article also explains resolving the tenant per request, assigning its ID to new rows, and adding partitions to migrations with raw SQL. The primary key must include GuildId, a constraint SQL Server imposes when partitioning a unique index.

Banner over a photograph of apartment buildings, titled “Multi-Tenant .NET, Part 1 — Shared Database with Partitions,” with a crossed-swords emblem and an illustrated portrait.