EfCoreIsolationOptions class
View as MarkdownNamespace: Tenantry.EfCore · Package: Tenantry.EfCore · API reference
Options for EF Core tenant isolation: the application's, set with tenant.ConfigureEfCoreIsolation(options => …), or one context's, set with options.UseTenantry(o => …).
Reads always fail closed, a new entity that names another tenant is always rejected, and ExecuteUpdate can never set TenantId. Whenever a tenant is current, Modified and Deleted entities must belong to it, checked before saving and again in each UPDATE and DELETE. These options decide what happens to writes without a tenant, to saves without a transaction, and to entity types neither tenant-owned nor shared. Database.SqlQuery, ExecuteSql and IgnoreQueryFilters() are outside Tenantry's isolation.
public sealed class EfCoreIsolationOptionsProperties
OnMissingTenant
What a save does when it writes tenant-owned entities and no tenant is current. Defaults to MissingTenantBehavior.Reject. Saves that write no tenant-owned entity are never affected.
public MissingTenantBehavior OnMissingTenant { get; set; }Value: MissingTenantBehavior
OnSaveWithoutTransaction
What a save does when AutoTransactionBehavior is Never and some of its rows depend on another statement's tenant check (owned rows in their own table, an entity split across tables, or many-to-many join rows). Defaults to SaveWithoutTransactionBehavior.UseTransaction.
public SaveWithoutTransactionBehavior OnSaveWithoutTransaction { get; set; }Value: SaveWithoutTransactionBehavior
OnUnmarkedEntityType
What a context does when its model has tenant-owned entity types and also entity types that are neither tenant-owned nor marked as shared across tenants. Defaults to UnmarkedEntityTypeBehavior.Allow.
public UnmarkedEntityTypeBehavior OnUnmarkedEntityType { get; set; }Value: UnmarkedEntityTypeBehavior
Mark an entity type whose rows every tenant shares with SharedAcrossTenantsAttribute or IsSharedAcrossTenants(). TenantModel.FindUnisolatedEntityTypes lists the types this checks.
SharedHybridCache class
The HybridCache for entries every tenant shares (exchange rates, reference data), where IsolateCaches() makes the injected HybridCache keep entries per tenant.
ITenantDbContextOptionsContributor interface
An extension point: for code that extends the package, such as another package that builds on it.