Docs
Tenantry ProAPI reference

ITenantSeeder<TKey> interface

Namespace: Tenantry.Pro.Lifecycle · Package: Tenantry.Pro · API reference

Consumer-implemented interface for seeding initial data into a new tenant's database. Register an implementation in DI before calling ITenantLifecycleManager<TKey>.ProvisionAsync:

services.AddScoped<ITenantSeeder<Guid>, MyTenantSeeder>();
public interface ITenantSeeder<TKey> where TKey : IEquatable<TKey>, IParsable<TKey>

Type parameters

  • TKey: The tenant identifier type.

Methods

SeedAsync(ITenantDescriptor<TKey>, IServiceProvider, CancellationToken)

Seeds default data for the given tenant. Called within a DI scope where all scoped services (DbContext, repositories, etc.) are tenant-aware — the tenant context is already set.

Task SeedAsync(ITenantDescriptor<TKey> tenant, IServiceProvider scopedProvider, CancellationToken cancellationToken)

Parameters:

  • tenant ITenantDescriptor<TKey>: The tenant being provisioned.
  • scopedProvider IServiceProvider: An IServiceProvider scoped to this tenant. Resolve your DbContext or other services from here.
  • cancellationToken CancellationToken: A cancellation token.

Returns: Task

On this page