Multitenancy with .NET and EF Core: A Deep Dive (.NET 10)
Ever had a multi-tenant SaaS app where the only thing stopping Customer A from seeing Customer B's invoices is a Where TenantId == clause someone remembered to write? In this deep dive I build real tenant isolation into EF Core 10 - two real tenants with real registration, login and invite flows (no dev-token shortcuts), a named global query filter that scopes every query automatically, and a SaveChangesAsync override that stamps TenantId on every insert so it's never left unset. I also show the one gotcha that makes EF Core 10 worth the upgrade for this: named query filters, so tenant isolation and soft-delete can finally coexist on the same entity instead of one silently overwriting the other. If you've ever shipped multi-tenancy on hope and code review, this is the version that makes the mistake structurally impossible.