DbContextOptionsBuilderExtensions class
Namespace: Tenantry.Pro.EfCore.Extensions · Package: Tenantry.Pro.EfCore · API reference
Extension methods for wiring Tenantry.Pro schema-per-tenant services into DbContextOptionsBuilder.
public static class DbContextOptionsBuilderExtensionsMethods
AddSchemaPerTenantCaching(DbContextOptionsBuilder, IServiceProvider)
Configures EF Core model caching for schema-per-tenant isolation.
public static DbContextOptionsBuilder AddSchemaPerTenantCaching(this DbContextOptionsBuilder optionsBuilder, IServiceProvider serviceProvider)Parameters:
optionsBuilderDbContextOptionsBuilder: The options builder for the application'sDbContext.serviceProviderIServiceProvider: The application service provider from theAddDbContextfactory callback.
Returns: DbContextOptionsBuilder: The same optionsBuilder for chaining.
Requires pro.AddSchemaPerTenantCaching<TKey>() to have been called during service registration so the tenant type is known without specifying it here.
AddSchemaPerTenantCaching<TKey>(DbContextOptionsBuilder, IServiceProvider)
Configures EF Core model caching for schema-per-tenant isolation.
public static DbContextOptionsBuilder AddSchemaPerTenantCaching<TKey>(this DbContextOptionsBuilder optionsBuilder, IServiceProvider serviceProvider) where TKey : IEquatable<TKey>, IParsable<TKey>Type parameters:
TKey: The tenant identifier type. Must match the key type used in the Tenantry DI registration.
Parameters:
optionsBuilderDbContextOptionsBuilder: The options builder for the application'sDbContext.serviceProviderIServiceProvider: The application service provider from theAddDbContextfactory callback. This is used so the custom model cache key factory can resolve the currentITenantContext<TKey>from application DI.
Returns: DbContextOptionsBuilder: The same optionsBuilder for chaining.
Use this together with pro.UseSchemaPerTenant(...) and pro.AddSchemaPerTenantCaching(), which registers the model cache key factory this uses. Your DbContext must also apply the tenant schema in OnModelCreating, typically via modelBuilder.HasDefaultSchema(_schemaNameResolver.Resolve()).
DbContextOptionsBuilderAuditExtensions class
Extension methods for wiring Tenantry.Pro.EfCore.Audit into an EF Core DbContext.
MigrationOrchestratorService<TKey, TContext> class
Runs pending EF Core migrations across all tenant databases discovered via ITenantStore<TKey>https://tenantry.dev/docs/core/api/tenantry-core-itenantstore.