using Microsoft.EntityFrameworkCore; public sealed class LabDb : DbContext { public string TenantId { get; } public LabDb(DbContextOptions options, string tenantId) : base(options) { if (string.IsNullOrWhiteSpace(tenantId)) throw new System.ArgumentException("Trusted tenant required", nameof(tenantId)); TenantId = tenantId; } public DbSet Items => Set(); protected override void OnModelCreating(ModelBuilder model) { model.Entity().HasQueryFilter("Tenant", x => x.TenantId == TenantId).HasQueryFilter("NotDeleted", x => !x.IsDeleted); } } public sealed class Item { public int Id { get; set; } public string Name { get; set; } = ""; public string TenantId { get; set; } = ""; public bool IsDeleted { get; set; } }