Tenantry ProAPI reference
HealthCheckBuilderExtensions class
Namespace: Tenantry.Pro.HealthChecks.Extensions · Package: Tenantry.Pro.HealthChecks · API reference
Extension methods for adding Tenantry.Pro health checks to the ASP.NET Core health check pipeline.
public static class HealthCheckBuilderExtensionsMethods
AddTenantryDatabaseCheck<TKey>(IHealthChecksBuilder, Action<TenantHealthCheckOptions>)
Adds a health check that verifies all tenant databases are reachable. Reports per-tenant connectivity in the health check data dictionary.
public static IHealthChecksBuilder AddTenantryDatabaseCheck<TKey>(this IHealthChecksBuilder builder, Action<TenantHealthCheckOptions> configure) where TKey : IEquatable<TKey>, IParsable<TKey>Type parameters:
TKey: The tenant identifier type.
Parameters:
builderIHealthChecksBuilder: The health checks builder.configureAction<TenantHealthCheckOptions>: Configure health check options. At minimum setTenantHealthCheckOptions.ConnectionFactoryto a delegate that creates aDbConnectionfor your database provider.
Returns: IHealthChecksBuilder: The same builder for chaining.
builder.Services.AddHealthChecks()
.AddTenantryDatabaseCheck<Guid>(opts =>
opts.ConnectionFactory = connStr => new SqlConnection(connStr));AddTenantryMigrationCheck<TKey, TContext>(IHealthChecksBuilder, Func<string, TContext>)
Adds a health check that verifies all tenant databases have current EF Core migrations. Reports pending migration names per tenant in the health check data dictionary.
[RequiresDynamicCode("EF Core migrations use dynamic code generation and are not AOT-safe.")]
[RequiresUnreferencedCode("EF Core migrations use reflection and are not trim-safe.")]
public static IHealthChecksBuilder AddTenantryMigrationCheck<TKey, TContext>(this IHealthChecksBuilder builder, Func<string, TContext> contextFactory) where TKey : IEquatable<TKey>, IParsable<TKey> where TContext : DbContextType parameters:
TKey: The tenant identifier type.TContext: The consumer's EF CoreDbContexttype.
Parameters:
builderIHealthChecksBuilder: The health checks builder.contextFactoryFunc<string, TContext>: A factory that accepts a per-tenant connection string and returns a configuredTContextto query pending migrations from.
Returns: IHealthChecksBuilder: The same builder for chaining.