
Part 2/4 shows how to isolate each tenant’s data in its own SQL Server schema, without a global query filter or a required TenantId column. EF Core can use a simple primary key again, while the database structure itself enforces the isolation boundary.
The key change is model caching: OnModelCreating runs only once per model. The schema must be included in the cache key through IModelCacheKeyFactory, or EF Core may reuse the first tenant’s schema. The article also covers per-schema provisioning and migrations, plus strict validation of schema names interpolated into SQL.
BarretFound via C# Digest



























