using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; namespace APT.Infrastructure.EF { public sealed class TenantModelCacheKeyFactory : ModelCacheKeyFactory where TDbContext : DbContext, ITenantDbContext { public override object Create(DbContext context) { var dbContext = context as TDbContext; return new TenantModelCacheKey(dbContext, dbContext?.Tenant?.Name ?? "no_tenant_identifier"); } public TenantModelCacheKeyFactory(ModelCacheKeyFactoryDependencies dependencies) : base(dependencies) { } } }