Docs
Tenantry Pro

Tenantry.Pro documentation

View as Markdown

Tenantry.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

  1. Installation: the private package feed, its credentials, CI and the licence key.
  2. Getting started: build a database-per-tenant app end to end.
  3. Licensing: the licence key, checked offline at startup, which does not expire.

Isolation strategies

  1. Database per tenant: connection strings, caching, pooling and database provisioning.
  2. Schema per tenant: schema names, EF Core's model per schema, and schema provisioning.
  3. Mixed mode: each tenant on its own database, its own schema or the shared database.
  4. Database providers: SQL Server, PostgreSQL and MySQL, and what was tested.

Operations

  1. Tenant migrations: migrating every tenant database and schema, and their status.
  2. Tenant lifecycle: provisioning a tenant (create, migrate, seed, your own steps) and offboarding one.
  3. Audit logging: recording each tenant's entity changes.
  4. Health checks: tenant database connectivity and pending migrations.
  5. Telemetry: the tenant in jobs' and messages' logs and traces, and Pro's log events.

Background work & messaging

  1. Background jobs & non-HTTP hosts: work for each tenant in workers and console apps.
  2. Hangfire, MassTransit, Quartz.NET, Rebus: the tenant in each library's jobs and messages.

Reference

  1. Testing: the licence key in tests and CI, and testing provisioning, migrations, jobs and messages.
  2. Compatibility: supported .NET, EF Core, database and library versions.
  3. Troubleshooting: common problems, and trimming and AOT.
  4. 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 database

With 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's AddDbContextPerTenantDatabase or EF Core's AddDbContext, 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.

On this page