Tenantry.Pro documentation
View as MarkdownTenantry.Pro adds a schema per tenant, mixed mode and the tooling many tenant databases need to
Tenantry. It runs inside a Tenantry registration: keep
AddTenantry, your resolvers and your store, and add tenant.UsePro(...).
New to it? Start with Installation, then Getting started.
Guides
Foundations
- Installation: the private package feed, its credentials, CI and the licence key.
- Getting started: build a database-per-tenant app end to end.
- Licensing: the licence key, checked offline at startup, which does not expire.
Isolation strategies
- Database per tenant: connection strings, caching, pooling and database provisioning.
- Schema per tenant: schema names, EF Core's model per schema, and schema provisioning.
- Mixed mode: each tenant on its own database, its own schema or the shared database.
- Database providers: SQL Server, PostgreSQL and MySQL, and what was tested.
Operations
- Tenant migrations: migrating every tenant database and schema, and their status.
- Tenant lifecycle: provisioning a tenant (create, migrate, seed, your own steps) and offboarding one.
- Audit logging: recording each tenant's entity changes.
- Health checks: tenant database connectivity and pending migrations.
- Telemetry: the tenant in jobs' and messages' logs and traces, and Pro's log events.
Background work & messaging
- Background jobs & non-HTTP hosts: work for each tenant in workers and console apps.
- Hangfire, MassTransit, Quartz.NET, Rebus: the tenant in each library's jobs and messages.
Reference
- Testing: the licence key in tests and CI, and testing provisioning, migrations, jobs and messages.
- Compatibility: supported .NET, EF Core, database and library versions.
- Troubleshooting: common problems, and trimming and AOT.
- API reference: every public type and member.
An AI coding agent adding Tenantry to an application follows Tenantry Core's guide for AI coding agents first: its steps, isolation test and rules apply with Pro too.
A request
A database-per-tenant request flows like this:
HTTP request
│
▼
UseTenantry() ──► Tenantry core resolves the tenant and opens the tenant scope
│
▼
AddDbContextPerTenantDatabase ──► ITenantConnectionStringProvider<TKey> ──► per-tenant connection string
│ (optionally cached by Pro)
▼
Your endpoint + EF Core ──► reads and writes hit the tenant's own databaseWith a schema per tenant, the connection string is shared and the tenant's schema becomes the model's default
schema. In a console or worker app there is no request, so you open the tenant's scope with
ITenantScopeFactory<TKey>; the rest is the same.
What Tenantry.Pro does not do
- It does not register your
DbContext: you do, with Tenantry core'sAddDbContextPerTenantDatabaseor EF Core'sAddDbContext, and keep control of its options. - It does not make up connection strings or schema names: you supply the delegates.
- It never provisions or migrates a tenant on its first request. You provision tenants explicitly, and run
migrations as a deployment step or, if you opt in with
o.OnStartup, at startup. - It does not replace Tenantry core's resolution, stores or shared-database isolation.
- It has no admin dashboard or UI.
TenantOptionsBuilder<TKey> class
Sets options per tenant, in tenant.ConfigurePerTenant(...): each Configure or ConfigureAll names an options type and what differs for each tenant.
Installation
Tenantry.Pro's packages are published to a private GitHub Packages feed owned by the tenantry-org GitHub organisation.