Skip to content

Multi-tenancy

NetForge ships with always-on multi-tenancy plumbing that stays invisible until you turn it on — single-tenant developers see no "tenant" anywhere. Flip it with one config setting:

jsonc
"Tenancy": { "Mode": "MultiTenant", "Resolution": "UserClaim" } // or Subdomain | Path | Header

Tenant switcher in the top bar

What you get when it's on

  • Tenant catalog/admin/tenants (host admins, tenants.*) lists, creates, and edits tenants; each has a name, status (Active/Suspended), brand colour, and logo. The default tenant can't be deleted.
  • Per-tenant roles — a user's roles are scoped to a tenant. The same person can be Admin in one tenant and a read-only member in another; permissions re-project the moment they switch. Role definitions are shared; the assignment is per-tenant.
  • Tenant switcher — a top-bar control lists the tenants you belong to; switching re-tints the app with that tenant's branding and reloads into its data.
  • Invitations — invite someone by email to a tenant with a role; they get a signed link to an accept page. Pending invitations can be revoked.
  • Isolation — every tenant-scoped record carries a TenantId and is filtered automatically, so one tenant never sees another's data.

Tenants admin list with per-tenant branding

Resolution strategies

The active tenant always derives from the signed-in user, so a forged subdomain or header can't reach a tenant you don't belong to. The strategy decides how an unauthenticated request is mapped:

StrategyExampleBest for
UserClaimfrom the signed-in userlocalhost / SPA
Subdomainacme.app.comclassic SaaS
Path/acme/…single-domain hosting
HeaderX-Tenant-IdAPI clients

Making a feature tenant-aware

Add the ITenantScoped marker to an entity and a global WHERE TenantId = current filter is applied automatically; new rows are stamped with the active tenant on save. That's the whole change — the switcher, invitations, and resolution are already wired. It composes with the normal Add a feature flow: add the marker and the platform does the rest.

Community edition

Multi-tenancy management is a Pro feature; the always-on single-tenant scaffolding stays in every edition. See Editions.

NetForge Community is MIT-licensed. Pro is a commercial edition.