TenantModel class
Namespace: Tenantry.EfCore · Package: Tenantry.EfCore · API reference
An extension point: for code that extends the package, such as another package that builds on it. An application rarely needs it.
Reads which entity types of an EF Core model Tenantry isolates, for packages and tests that build on it.
[EditorBrowsable(EditorBrowsableState.Advanced)]
public static class TenantModelFields
SharedAcrossTenantsAnnotation
The model annotation IsSharedAcrossTenants() sets.
public const string SharedAcrossTenantsAnnotation = "Tenantry:SharedAcrossTenants"Returns: string
Methods
FindUnisolatedEntityTypes(IReadOnlyModel)
Returns the entity types of model that are neither tenant-owned nor marked as shared by every tenant. In a database that tenants share, Tenantry does not keep their rows apart.
public static IReadOnlyList<IReadOnlyEntityType> FindUnisolatedEntityTypes(IReadOnlyModel model)Parameters:
modelIReadOnlyModel: The model, such ascontext.Model.
Returns: IReadOnlyList<IReadOnlyEntityType>
HasTenantOwnedEntityTypes(IReadOnlyModel)
Returns whether model has an entity type that implements ITenantEntity<TKey>, which is what UseTenantry() isolates. A model without one has nothing for Tenantry's filters and checks to do.
public static bool HasTenantOwnedEntityTypes(IReadOnlyModel model)Parameters:
modelIReadOnlyModel: The model, such ascontext.Model.
Returns: bool
IsSharedAcrossTenants(IReadOnlyEntityType)
Returns whether entityType, or the type that owns it, is marked as shared by every tenant, with SharedAcrossTenantsAttribute or IsSharedAcrossTenants().
public static bool IsSharedAcrossTenants(IReadOnlyEntityType entityType)Parameters:
entityTypeIReadOnlyEntityType: The entity type.
Returns: bool
IsTenantOwned(IReadOnlyEntityType)
Returns whether entityType is tenant-owned: it implements ITenantEntity<TKey>, or it is an owned type whose owner is.
public static bool IsTenantOwned(IReadOnlyEntityType entityType)Parameters:
entityTypeIReadOnlyEntityType: The entity type.
Returns: bool