Tenantry CoreAPI reference
ServiceCollectionExtensions class
Namespace: Tenantry.AspNetCore.Extensions · Package: Tenantry.AspNetCore · API reference
Extension methods for registering Tenantry services.
public static class ServiceCollectionExtensionsMethods
AddTenantry<TKey>(IServiceCollection, Action<IAspNetCoreTenantBuilder<TKey>>)
Registers Tenantry services for ASP.NET Core and returns an IAspNetCoreTenantBuilder<TKey> for further configuration.
public static IServiceCollection AddTenantry<TKey>(this IServiceCollection services, Action<IAspNetCoreTenantBuilder<TKey>> configure) where TKey : IEquatable<TKey>, IParsable<TKey>Type parameters:
TKey: The tenant identifier type (e.g.Guid,int,string). Must implementIEquatable<T>andIParsable<TSelf>.
Parameters:
servicesIServiceCollection: The application's service collection.configureAction<IAspNetCoreTenantBuilder<TKey>>: Configures tenant resolution, the tenant store and access validation.
Returns: IServiceCollection
builder.Services.AddTenantry<Guid>(tenant =>
{
tenant.ResolveFromHeader("X-Tenant-Id");
tenant.UseInMemoryStore(tenants);
tenant.AddEfCoreIsolation(options => options.OnMissingTenant = MissingTenantBehavior.Reject);
});