SchemaProvisioningService<TKey> class
Namespace: Tenantry.Pro.EfCore.Npgsql.Strategies.SchemaPerTenant · Package: Tenantry.Pro.EfCore.Npgsql · API reference
Creates a dedicated PostgreSQL schema for a tenant when called explicitly.
Inject this service in the code path that creates new tenants and call SchemaProvisioningServiceBase<TKey>.ProvisionAsync explicitly.
public sealed class SchemaProvisioningService<TKey> : SchemaProvisioningServiceBase<TKey>, ITenantInfrastructureProvisioner<TKey> where TKey : IEquatable<TKey>, IParsable<TKey>Type parameters
TKey: The tenant identifier type.
Inherits SchemaProvisioningServiceBase<TKey>.
Implements ITenantInfrastructureProvisioner<TKey>.
Constructors
SchemaProvisioningService(ITenantStoreAccessor<TKey>, IOptions<SchemaPerTenantOptions<TKey>>, string, ILicenseGuard, ILogger<SchemaProvisioningService<TKey>>)
Creates the provisioning service. Resolved automatically by the DI container when you call pro.AddSchemaProvisioning(...); you do not normally construct it yourself.
public SchemaProvisioningService(ITenantStoreAccessor<TKey> storeAccessor, IOptions<SchemaPerTenantOptions<TKey>> options, string connectionString, ILicenseGuard licenseGuard, ILogger<SchemaProvisioningService<TKey>> logger)Parameters:
storeAccessorITenantStoreAccessor<TKey>: Resolves tenant descriptors.optionsIOptions<SchemaPerTenantOptions<TKey>>: Schema-per-tenant options (supplies the schema name).connectionStringstring: The shared-database connection string in which schemas are created.licenseGuardILicenseGuard: Guards provisioning behind a valid Tenantry.Pro licence.loggerILogger<SchemaProvisioningService<TKey>>: The logger.
Methods
CreateSchemaIfNotExistsAsync(string, string, CancellationToken)
Issues the provider-specific, idempotent CREATE SCHEMA against connectionString. Implementations are responsible for identifier escaping.
protected override Task CreateSchemaIfNotExistsAsync(string connectionString, string schemaName, CancellationToken cancellationToken)Parameters:
connectionStringstring: A connection string for the shared database.schemaNamestring: The name of the tenant's schema, unescaped.cancellationTokenCancellationToken: Cancels the operation.
Returns: Task