Finbuckle.
The library uses standard .NET Core conventions and most of the internal details are abstracted away from app code. However, there are a few important specifics to be aware of. The items below make up the foundation of the library.
TenantInfoA TenantInfo record instance contains information about a tenant. Often this will be the "current" tenant in the context an
app. These instances' type use or inherit from TenantInfo which defines properties
for Id, Identifier, Name. When calling AddMultiTenant<TTenantInfo> the type passed into the
type parameter defines the TenantInfo derived class used throughout the library and app. TenantInfo instances are
intended to be immutable and the with expression should be used to create modified copies.
Id is a unique id for a tenant in your app and should never change.Identifier is the value used to actually resolve a tenant and should have a syntax compatible for your app (i.e. no
crazy symbols in a web app where the identifier will be part of the URL). Unlike Id, Identifier can be changed if
necessary.Name is a display name for the tenant.TenantInfo is a base implementation. Your app can and should define a custom TenantInfo and add custom
properties as needed. It is recommended to keep these
classes lightweight since they are often queried. Keep heavier associated data in an external area that can be pulled in
when needed via the tenant Id.
Previous versions of
TenantInfoincluded a connection string property. If needed simply add it to your customTenantInfoderived class.
MultiTenantContext<TTenantInfo>The MultiTenantContext<TTenantInfo> contains information about the current tenant.
IMultiTenantContext and IMultiTenantContext<TTenantInfo> which can be obtained from dependency injection.TenantInfo, StrategyInfo, and StoreInfo properties with details on the current tenant, how it was
determined, and from where its information was retrieved.TenantInfo instance to help ensure immutability.HasTenant property indicates whether a tenant was successfully resolved for the current context.GetMultiTenantContext() method on the current request's HttpContext
object. The implementation used with ASP.NET Core middleware has read only properties. The HttpContext extension
method SetTenantInfo can be used to manually set the current tenant, but normally the middleware handles this.Responsible for determining and returning a tenant identifier string for the current request.
IMultiTenantStrategy can be used as well.Responsible for returning a TenantInfo object based on a tenant string identifier (which is usually provided by a
strategy).
TenantInfo objects.InMemoryTenantStore based on ConcurrentDictionary<string, TenantInfo>
and a more advanced Entity Framework Core based implementation.IMultiTenantStore can be used as well.Exception type thrown when a serious problem occurs within MultiTenant.