Pragmatic.MultiTenancy.AspNetCore 1.0.0-alpha.2

This is a prerelease version of Pragmatic.MultiTenancy.AspNetCore.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Pragmatic.MultiTenancy.AspNetCore --version 1.0.0-alpha.2
                    
NuGet\Install-Package Pragmatic.MultiTenancy.AspNetCore -Version 1.0.0-alpha.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Pragmatic.MultiTenancy.AspNetCore" Version="1.0.0-alpha.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Pragmatic.MultiTenancy.AspNetCore" Version="1.0.0-alpha.2" />
                    
Directory.Packages.props
<PackageReference Include="Pragmatic.MultiTenancy.AspNetCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Pragmatic.MultiTenancy.AspNetCore --version 1.0.0-alpha.2
                    
#r "nuget: Pragmatic.MultiTenancy.AspNetCore, 1.0.0-alpha.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Pragmatic.MultiTenancy.AspNetCore@1.0.0-alpha.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Pragmatic.MultiTenancy.AspNetCore&version=1.0.0-alpha.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Pragmatic.MultiTenancy.AspNetCore&version=1.0.0-alpha.2&prerelease
                    
Install as a Cake Tool

Pragmatic.MultiTenancy

Shared-schema multi-tenancy for the Pragmatic.Design ecosystem: tenant resolution, scoping, and automatic query filtering: zero config for single-tenant apps, pluggable strategies for SaaS.

The Problem

Multi-tenant SaaS must isolate data per tenant. Without framework support, every query must filter by tenant, every write must assign it, and every background job must propagate the tenant context. Miss one WHERE TenantId = @current and you have a cross-tenant data leak, something code review catches sometimes and tests catch never.

// Without Pragmatic: manual tenant filtering everywhere (easy to forget → data leak)
return await db.Invoices.Where(i => i.TenantId == currentTenantId).ToListAsync(ct);

Caching leaks too (invoices:latest returns the wrong tenant's data), and resolution varies (headers in dev, JWT in prod, subdomains for some APIs).

The Solution

Mark entities ITenantEntity; the generator filters and assigns the tenant automatically, and an AsyncLocal tenant context flows through async continuations (including background jobs).

[Entity]
public partial class Invoice : IEntity, ITenantEntity { /* TenantId set + filtered automatically */ }
// resolution strategy chosen once, in Program.cs
app.UseMultiTenancy(mt => mt.UseHeader());   // or UseClaim / UseSubdomain / UseRoute / UseResolver<T>
                                              // UseDbPerTenant(...) for DB-per-tenant (Persistence package)

Security. header / route / subdomain read the tenant from client-controlled input and are meant for pre-auth resolution. For authenticated requests the resolved tenant is validated against the user's tenant_id claim (fail-closed, HTTP 403 on mismatch): an authenticated user cannot escalate to another tenant by spoofing the header/route/host. See tenant-resolution.md.

Installation

dotnet add package Pragmatic.MultiTenancy.AspNetCore   # HTTP resolvers + UseMultiTenancy
dotnet add package Pragmatic.MultiTenancy.Persistence  # optional: DB-per-tenant
Package Role
Pragmatic.MultiTenancy Tenant context, scoping, configuration; no ASP.NET Core dependency
Pragmatic.MultiTenancy.AspNetCore Header/claim/subdomain/route resolvers, the resolution middleware, UseMultiTenancy
Pragmatic.MultiTenancy.Persistence DB-per-tenant: per-tenant connection strings, provisioning, migration orchestration

ITenantEntity lives in Pragmatic.Abstractions, so a domain module marks its entities without referencing any of these.

Status

Functional within 1.0.0-alpha: tenant resolution strategies, shared-schema filtering, database-per-tenant, and non-HTTP propagation. See the roadmap.

Documentation

Guide What you'll learn
Concepts The tenancy model, ITenantEntity, ambient context, cache scoping
Getting Started Mark entities, choose a resolver, wire the middleware
Tenant Resolution Header/claim/subdomain/route/custom resolvers, ordering, non-HTTP contexts
Common Mistakes The most frequent tenancy pitfalls
Troubleshooting Problem/solution guide

Requirements

  • .NET 10.0+

License

Part of the Pragmatic.Design ecosystem. See Licensing. Pragmatic.MultiTenancy is licensed under the PolyForm Small Business 1.0.0 license (free for small businesses; commercial license above the threshold).

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Pragmatic.MultiTenancy.AspNetCore:

Package Downloads
Pragmatic.MultiTenancy.Persistence

DB-per-tenant support for Pragmatic.Design. Provides tenant-aware connection string resolution, database provisioning, and migration orchestration.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-alpha.6 130 11/21/2026
1.0.0-alpha.5 58 11/21/2026
1.0.0-alpha.4 118 11/16/2026
1.0.0-alpha.3 513 10/17/2026
1.0.0-alpha.2 125 10/12/2026
1.0.0-alpha.1 346 10/3/2026