Tenantry CoreAPI reference
API reference
Every public type in the packages, generated from their XML documentation comments. The guides explain how the pieces fit together; this reference is for the details of each type and member.
Tenantry.AspNetCore
Tenantry.AspNetCore
| Type | Kind | Summary |
|---|---|---|
IAspNetCoreTenantBuilder<TKey> | interface | Fluent builder for configuring multi-tenancy services. Obtained from ServiceCollectionExtensions.AddTenantry<TKey>. |
Tenantry.AspNetCore.Attributes
| Type | Kind | Summary |
|---|---|---|
AllowMissingTenantAttribute | class | Allows an endpoint or controller action to execute without a resolved tenant. |
RequireTenantAttribute | class | Requires Tenantry to resolve a tenant before the endpoint or controller action executes. |
Tenantry.AspNetCore.Extensions
| Type | Kind | Summary |
|---|---|---|
ApplicationBuilderExtensions | class | Extension methods for adding Tenantry middleware to the request pipeline. |
EndpointConventionBuilderExtensions | class | Extension methods for applying Tenantry endpoint metadata. |
ServiceCollectionExtensions | class | Extension methods for registering Tenantry services. |
Tenantry.AspNetCore.Resolution
| Type | Kind | Summary |
|---|---|---|
ClaimTenantResolver | class | Resolves the tenant from a claim on the current request principal. |
HeaderTenantResolver | class | Resolves the tenant from a request header (e.g. X-Tenant-Id). |
ITenantResolver | interface | Extracts a tenant identifier from an HTTP request. |
QueryStringTenantResolver | class | Resolves the tenant from a query string parameter (e.g. ?tenantId=acme). |
RouteValueTenantResolver | class | Resolves the tenant from a route value (e.g. /api/{tenant}/resource). |
SubdomainTenantResolver | class | Resolves the tenant from the first subdomain segment of the request host. For example, acme.app.example.com resolves to acme. |
Tenantry.Core
Tenantry.Core
| Type | Kind | Summary |
|---|---|---|
ITenantBuilder<TKey> | interface | Minimal builder interface that captures TKey and exposes the service collection. Satellite packages (e.g. Tenantry.EfCore) add extension methods on this interface so users only specify TKey once in AddTenantry. |
ITenantConnectionStringResolver<TKey> | interface | Returns tenants' connection strings, as configured by TenantConnectionStringOptions<TKey>. |
ITenantContext<TKey> | interface | Provides read-only access to the currently resolved tenant for the active request scope. Registered as a singleton backed by AsyncLocal<T> — the value is per-async-context (effectively per HTTP request) rather than per-instance. |
ITenantDescriptor<TKey> | interface | Represents a resolved tenant. |
ITenantScope<TKey> | interface | Represents a scoped interface for managing tenant-specific context within the application. |
ITenantScopeFactory<TKey> | interface | Opens tenant scopes for work that runs outside an HTTP request: hosted services, queue consumers, scheduled jobs and console tools. Each scope pairs a fresh dependency-injection scope with an active tenant, so scoped services such as a DbContext are created for that tenant and isolated to it. |
ITenantScoped<TKey> | interface | Marker interface for objects that belong to a specific tenant. |
ITenantServiceScope<TKey> | interface | A dependency-injection scope with a tenant active, created by ITenantScopeFactory<TKey>. |
ITenantStore<TKey> | interface | Persists and retrieves tenant definitions. |
ITenantStoreAccessor<TKey> | interface | Reads tenants from the registered ITenantStore<TKey> on behalf of singletons, such as hosted services, resolving the store from a fresh dependency-injection scope for each call. |
MissingTenantBehavior | enum | Policy for what happens when a tenant-scoped operation runs without a resolved tenant context. |
TenantConnectionStringOptions<TKey> | class | How to find each tenant's connection string, for applications that give tenants their own database (or route them to different servers). Configure it with UseConnectionStrings and read connection strings through ITenantConnectionStringResolver<TKey>. |
TenantConnectionStringResolver<TKey> | class | The default ITenantConnectionStringResolver<TKey>: calls the configured delegates on every resolution, without caching. |
TenantDescriptor<TKey> | class | Default implementation of ITenantDescriptor<TKey>. |
TenantScoped<TKey> | class | Optional base class for tenant-owned objects. Implements ITenantScoped<TKey> for convenience. |
Tenantry.Core.Exceptions
| Type | Kind | Summary |
|---|---|---|
TenantIsolationViolationException | class | Thrown when a cross-tenant data isolation violation is detected during a SaveChanges or SaveChangesAsync call, or when a bulk update would set TenantId. |
TenantNotResolvedException | class | Thrown when a tenant could not be resolved from the current request context and the operation requires a resolved tenant. |
Tenantry.Core.Extensions
| Type | Kind | Summary |
|---|---|---|
ConnectionStringExtensions | class | Registers per-tenant connection strings: TenantConnectionStringOptions<TKey> and ITenantConnectionStringResolver<TKey>. |
ServiceCollectionExtensions | class | Extension methods for registering core Tenantry services. |
Tenantry.Core.Stores
| Type | Kind | Summary |
|---|---|---|
InMemoryTenantStore<TKey> | class | An ITenantStore<TKey> backed by an in-memory dictionary. |
Tenantry.EfCore
Tenantry.EfCore
| Type | Kind | Summary |
|---|---|---|
EfCoreIsolationOptions | class | Options for configuring EF Core tenant isolation registration. Passed to builder.AddEfCoreIsolation(options => ...). |
ITenantAwareDbContext<TKey> | interface | Marks a DbContext as tenant-aware, exposing the current tenant identifier for use in EF Core global query filters. |
MultiTenantDbContext<TKey> | class | Optional base DbContext that automatically applies tenant query filters in OnModelCreating. |
Tenantry.EfCore.Extensions
| Type | Kind | Summary |
|---|---|---|
DbContextOptionsBuilderExtensions | class | Extension methods for wiring Tenantry into DbContextOptionsBuilder. |
TenantBuilderEfCoreExtensions | class | Extension methods for configuring EF Core tenant isolation on ITenantBuilder<TKey>. |
TenantDbContextPoolExtensions | class | DbContext pooling for applications that give each tenant its own database. |
TenantModelBuilderExtensions | class | Extension methods for ModelBuilder that apply tenant isolation to all entities implementing ITenantScoped<TKey>. |