EricksonLopez.MultiTenancy
dotnet-multitenancy · Multi-Tenancy & Security
On this page (20 sections)
1. Identity, Tier & Maturity Profile#
2. Value Proposition & Problem Solved#
Native AOT-first multi-tenancy ecosystem for modern .NET & ASP.NET Core with 4-layer Defense-in-Depth isolation across PostgreSQL RLS, SQL Server, MySQL, MariaDB, Oracle VPD, and SQLite.
Application-only LINQ query filters are bypassed by raw Dapper queries, views, or stored procedures, exposing multi-tenant applications to connection-pool session bleeding.
3. Quick Install#
Primary package: EricksonLopez.MultiTenancy
dotnet add package EricksonLopez.MultiTenancy --version 2.0.0<PackageReference Include="EricksonLopez.MultiTenancy" Version="2.0.0" /><PackageVersion Include="EricksonLopez.MultiTenancy" Version="2.0.0" />4. Verified Ecosystem Metrics#
Snapshot retrieved UTC: 2026-12-01
5. When to Use & When Not to Use#
When to use
- You need 4-layer Defense-in-Depth tenant isolation combining ASP.NET Core resolution, TenantId structs, and database RLS/SESSION_CONTEXT.
When NOT to use
- You operate a single-tenant application with no tenant boundary requirements.
6. Core Capabilities & Design Invariants#
Zero-Allocation TenantId & Resolution
128-bit TenantId struct with span parsing plus HostName, Route, BasePath, Header, and Static strategies.
Database RLS & Session Isolation
Transaction-scoped adapters for PostgreSQL RLS, SQL Server SESSION_CONTEXT, MySQL/MariaDB, Oracle VPD, and SQLite.
7. Included NuGet Packages & Adapters#
| Package ID | Status | NuGet / Local | TFMs | AOT Status | Downloads | Description |
|---|---|---|---|---|---|---|
| EricksonLopez.MultiTenancyPrimary | Published | v2.0.0 / v3.1.0 | net8.0, net9.0, net10.0 | AOT: Full | 347 | Core implementation, ambient context accessors, in-memory stores and lifecycle management for multi-tenant SaaS applications in .NET 8.0 and .NET 9.0. |
| EricksonLopez.MultiTenancy.Abstractions | Published | v2.0.0 / v3.1.0 | net8.0, net9.0, net10.0 | AOT: Full | 675 | Foundation contracts and primitives for multi-tenant SaaS architecture in .NET 8.0 and .NET 9.0. Contractually relies on EricksonLopez.Result for domain/infrastructure error modeling. |
| EricksonLopez.MultiTenancy.AspNetCore | Published | v2.0.0 / v3.1.0 | net8.0, net9.0, net10.0 | AOT: Full | 308 | ASP.NET Core integration for multi-tenant SaaS applications: resolution middleware, endpoint filters and strategies (Header, Host, Claims, Route). |
| EricksonLopez.MultiTenancy.Configuration | Published | v2.0.0 / v3.1.0 | net8.0, net9.0, net10.0 | AOT: Full | 301 | Microsoft.Extensions.Configuration and Options integration for EricksonLopez.MultiTenancy, enabling dynamic tenant configuration loading from appsettings and configuration providers. |
| EricksonLopez.MultiTenancy.Authentication | Published | v2.0.0 / v3.1.0 | net8.0, net9.0, net10.0 | AOT: Full | 286 | ASP.NET Core authentication and cookie security integration for multi-tenant applications, preventing cross-tenant cookie hijacking and tenant hopping. |
| EricksonLopez.MultiTenancy.Sqlite | Published | v2.0.0 / v3.1.0 | net8.0, net9.0, net10.0 | AOT: Full | 286 | SQLite multi-tenant integration for EricksonLopez.MultiTenancy. Provides database-per-tenant dynamic connection string resolution, session temporary context, and transaction management with Microsoft.Data.Sqlite and Dapper. |
| EricksonLopez.MultiTenancy.Dapper | Published | v2.0.0 / v3.1.0 | net8.0, net9.0, net10.0 | AOT: Full | 285 | Dapper integration for multi-tenant applications: tenant parameter injection and connection string resolution. |
| EricksonLopez.MultiTenancy.PostgreSql | Published | v2.0.0 / v3.1.0 | net8.0, net9.0, net10.0 | AOT: Full | 285 | PostgreSQL Row Level Security (RLS) integration for EricksonLopez.MultiTenancy. Provides transaction-scoped tenant context propagation via SET LOCAL for connection-pool-safe tenant isolation. |
| EricksonLopez.MultiTenancy.SqlServer | Published | v2.0.0 / v3.1.0 | net8.0, net9.0, net10.0 | AOT: Incompatible | 284 | Microsoft SQL Server Row-Level Security (RLS) and SESSION_CONTEXT integration for EricksonLopez.MultiTenancy. Provides session-context and transaction-scoped tenant isolation via sp_set_session_context. |
| EricksonLopez.MultiTenancy.Oracle | Published | v2.0.0 / v3.1.0 | net8.0, net9.0, net10.0 | AOT: Incompatible | 282 | Oracle Virtual Private Database (VPD) and Fine-Grained Access Control (FGAC) multi-tenant integration for EricksonLopez.MultiTenancy. Sets DBMS_SESSION.SET_IDENTIFIER and Oracle ClientId for tenant isolation with Oracle.ManagedDataAccess.Core and Dapper. |
| EricksonLopez.MultiTenancy.MariaDb | Published | v2.0.0 / v3.1.0 | net8.0, net9.0, net10.0 | AOT: Full | 280 | MariaDB multi-tenant isolation and session variable integration for EricksonLopez.MultiTenancy. Provides transaction and connection-level tenant isolation for MariaDB using MySqlConnector and Dapper. |
| EricksonLopez.MultiTenancy.Testing | Published | v2.0.0 / v3.1.0 | net8.0, net9.0, net10.0 | AOT: Full | 277 | Testing helpers, test doubles, and fluent builders for EricksonLopez.MultiTenancy. |
| EricksonLopez.MultiTenancy.MySql | Published | v2.0.0 / v3.1.0 | net8.0, net9.0, net10.0 | AOT: Full | 267 | MySQL session variable and multi-tenant isolation integration for EricksonLopez.MultiTenancy. Sets connection/transaction-level session variables for tenant isolation with MySqlConnector and Dapper. |
| EricksonLopez.MultiTenancy.OpenTelemetry | Published | v2.0.0 / v3.1.0 | net8.0, net9.0, net10.0 | AOT: Full | 267 | OpenTelemetry distributed tracing, metrics, and W3C baggage propagation for EricksonLopez.MultiTenancy. |
| EricksonLopez.MultiTenancy.AnalyzersAnalyzer / Generator | Published | v2.0.0 / v3.1.0 | netstandard2.0 | AOT: N/A (Analyzer/Legacy) | 255 | Roslyn Analyzers for EricksonLopez.MultiTenancy lifecycle and invariant safety. |
| EricksonLopez.MultiTenancy.Caching | Unpublished | — / v3.1.0 | net8.0, net9.0, net10.0 | AOT: Full | 0 | Multi-tenant distributed caching decorator and key partitioning for EricksonLopez.MultiTenancy. |
8. Quick Start Code Example#
Grounded in verified public APIs from EricksonLopez.MultiTenancy. Compile with `<ImplicitUsings>disable</ImplicitUsings>` and explicit imports.
using System;
using EricksonLopez.MultiTenancy;
var tenantId = TenantId.Create("11111111-1111-1111-1111-111111111111");
if (TenantId.TryCreate("22222222-2222-2222-2222-222222222222", out var parsedId))
{
var tenantInfo = new TenantInfo(id: parsedId, name: "acme-corp", isActive: true);
Console.WriteLine($"{tenantId} -> {tenantInfo.Name}");
}9. Architecture & Dependency Flow#
Rendering diagram…
flowchart LR lib_multitenancy["EricksonLopez.MultiTenancy (L2)"] lib_result["EricksonLopez.Result (L0)"] lib_multitenancy --> lib_result
View accessible text summary and structure
1 upstream library dependencies and 0 downstream dependent libraries verified in dependencies.json.
| Direction | Library | Tier | Relationship Kinds |
|---|---|---|---|
| Upstream | EricksonLopez.Result | L0 | Compile-Time, NuGet Package |
flowchart LR
lib_multitenancy["EricksonLopez.MultiTenancy (L2)"]
lib_result["EricksonLopez.Result (L0)"]
lib_multitenancy --> lib_result10. Target Frameworks & Native AOT / Trimming Matrix#
MSBuild `.csproj` inspection across 16 packages: 13 Full, 0 Partial, 2 Incompatible, 1 NotApplicable (analyzers/generators).
| Package ID | IsAotCompatible | EnableTrimAnalyzer | Verified AOT Status | Target Frameworks |
|---|---|---|---|---|
| EricksonLopez.MultiTenancy | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.MultiTenancy.Abstractions | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.MultiTenancy.AspNetCore | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.MultiTenancy.Configuration | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.MultiTenancy.Authentication | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.MultiTenancy.Sqlite | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.MultiTenancy.Dapper | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.MultiTenancy.PostgreSql | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.MultiTenancy.SqlServer | false | false | Incompatible | net8.0, net9.0, net10.0 |
| EricksonLopez.MultiTenancy.Oracle | false | false | Incompatible | net8.0, net9.0, net10.0 |
| EricksonLopez.MultiTenancy.MariaDb | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.MultiTenancy.Testing | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.MultiTenancy.MySql | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.MultiTenancy.OpenTelemetry | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.MultiTenancy.Analyzers | false | false | NotApplicable | netstandard2.0 |
| EricksonLopez.MultiTenancy.Caching | true | true | Full | net8.0, net9.0, net10.0 |
11. Upstream Dependencies & Downstream Dependents#
Upstream Dependencies (1)
Downstream Dependents (0)
No other EricksonLopez.* libraries currently depend on this family.
12. Optional Adapters & Third-Party Integrations#
Internal Adapter Edges & Integration Packages
No optional cross-family adapter edges or integration packages are recorded for this library.
Verified External NuGet Dependencies (16)
13. Configuration & DI Registration Summary#
Verified DI & Configuration Entry Points
AspNetCoreMultiTenancyExtensions.AddAspNetCoreMultiTenancyRegisters ASP.NET Core tenant resolution strategies and context accessor in the service collection.
AspNetCoreMultiTenancyExtensions.AddBasePathStrategyRegisters a URL base path segment tenant resolution strategy in the service collection.
AspNetCoreMultiTenancyExtensions.AddDelegateTenantStrategyRegisters a delegate-based tenant resolution strategy in the service collection.
AspNetCoreMultiTenancyExtensions.AddHostNameTenantStrategyRegisters a host name and subdomain tenant resolution strategy in the service collection.
AspNetCoreMultiTenancyExtensions.AddInternalHeaderTenantResolutionRegisters a header-based tenant resolution strategy for internal service-to-service communication.
AspNetCoreMultiTenancyExtensions.AddMultiPlaneAspNetCoreRegisters multi-plane execution context services and ASP.NET Core anti-header-spoofing options.
AspNetCoreMultiTenancyExtensions.AddRouteTenantStrategyRegisters a route-based tenant resolution strategy in the service collection.
AspNetCoreMultiTenancyExtensions.AddStaticTenantStrategyRegisters a static tenant resolution strategy in the service collection.
AspNetCoreMultiTenancyExtensions.AddTenantRouteConstraintRegisters the `Routing.TenantRouteConstraint` for use in ASP.NET Core routing.
AspNetCoreMultiTenancyExtensions.UseMultiPlaneContextAdds the `MultiPlaneContextMiddleware` to the application request pipeline to scrub untrusted headers and bind verified multi-plane principal claims.
AspNetCoreMultiTenancyExtensions.UseMultiTenancyAdds the `TenantResolutionMiddleware` to the application request pipeline.
InMemoryTenantStore<TTenant>.AddOrUpdateAdds or updates tenant metadata in the in-memory store.
Key Public Types & Contracts
EricksonLopez.MultiTenancy.AmbientMultiPlaneContextAccessor (class)Provides a thread-safe and async-flow-safe `IMultiPlaneContextAccessor` backed by `AsyncLocal<T>` with optional fallback resolution for HTTP request scopes.
EricksonLopez.MultiTenancy.AmbientTenantContextHolder (class)Provides an ambient context holder for background job scopes and decoupled workers where `HttpContext` is unavailable.
EricksonLopez.MultiTenancy.AspNetCoreMultiTenancyExtensions (class)Provides extension methods for ASP.NET Core multi-tenancy registration and pipeline configuration.
EricksonLopez.MultiTenancy.DefaultTenantScopeFactory (class)Provides a factory that creates isolated dependency injection scopes with pre-populated tenant context for background jobs and message consumers.
EricksonLopez.MultiTenancy.ExecutionPlane (enum)Defines the canonical security and execution planes isolating platform operators, customer interactive users, machine-to-machine principals, and Day-0 bootstrap tasks.
EricksonLopez.MultiTenancy.ExecutionPlaneExtensions (class)Provides wire-format serialization and zero-allocation parsing helpers for `ExecutionPlane`.
EricksonLopez.MultiTenancy.IBranchContext (interface)Provides access to branch / operational location context within a multi-tenant hierarchy.
EricksonLopez.MultiTenancy.ICompanyContext (interface)Provides access to ambient company/legal entity context within a multi-tenant hierarchy.
EricksonLopez.MultiTenancy.IMultiPlaneContext (interface)Represents a unified, immutable multi-plane execution context spanning HTTP/gRPC/SignalR transports, background workers, message consumers, and Day-0 bootstrap runners. Supports both single-level SaaS (`TenantId`) and 1:N Holding hierarchies (`TenantId` + `ICompanyContext.CompanyId`).
EricksonLopez.MultiTenancy.IMultiPlaneContextAccessor (interface)Provides access to and deterministic lexical scoping for the active `IMultiPlaneContext` across HTTP requests, background jobs, schedulers, and message queue consumers.
EricksonLopez.MultiTenancy.IOrganizationContext (interface)Defines a unified organization hierarchy contract combining tenant, company, and branch isolation contexts.
EricksonLopez.MultiTenancy.IPlatformAdminContext (interface)Represents an authenticated platform administrative execution context authorized to perform cross-tenant operations.
14. Verified Performance Benchmarks#
All verified measurements below come strictly from `BenchmarkDotNet.Artifacts` running on .NET RyuJIT (0 NativeAOT benchmark runs exist in this snapshot).
No non-MEGA-AUDIT `BenchmarkDotNet.Artifacts` files were verified for this library in the snapshot (`hasBenchmarks: false`).
15. Release History & NuGet vs Repo Status#
Version lag detected: NuGet.org latest published version is v2.0.0, while local repository HEAD is at v3.1.0.
| Version | Source | Published Date | Summary |
|---|---|---|---|
| v2.0.0 ↗ | nuget | 2026-09-23 | Published EricksonLopez.MultiTenancy 2.0.0 to NuGet.org. |
| v2.0.0 ↗ | github | 2026-09-23 | [2.0.0](https://github.com/ericksonlopezf/dotnet-multitenancy/compare/v1.0.0...v2.0.0) (2026-09-23) ⚠ BREAKING CHANGES * implement multi-tier hierarchy, session invariants, and fail-closed resolution ✨ Features * implement multi-tier hierarchy, session invariants, and fail-closed resolution ([f6e3992](https://github.com/ericksonlopezf/dotnet-multitenancy/commit/f6e3992c384e48913a8d50064eb5ac2c2... |
| v1.0.0 ↗ | github | 2026-08-27 | Ecosystem Packages in this release | Package | Version | |---------|---------| | `EricksonLopez.MultiTenancy.Abstractions` | `1.0.0` | | `EricksonLopez.MultiTenancy` | `1.0.0` | | `EricksonLopez.MultiTenancy.AspNetCore` | `1.0.0` | | `EricksonLopez.MultiTenancy.Authentication` | `1.0.0` | | `EricksonLopez.MultiTenancy.Configuration` | `1.0.0` | | `EricksonLopez.MultiTenancy.Dapper` | `1.0.0` | ... |
| v1.0.0 ↗ | nuget | 2026-08-27 | Published EricksonLopez.MultiTenancy 1.0.0 to NuGet.org. |
16. Complementary & Related Libraries#
Libraries in the same tier, architectural layer, or directly paired via dependency edges.
17. Documentation, API Reference & Portal Links#
Conceptual Documentation (Starlight) →
Extracted XML API Reference →
24 namespaces · 149 types · 748 members
Ecosystem Dependency Map →
Learning Center & Handbook →
Per-library conceptual Starlight pages expand in M4; API Reference pages expand in M3.2.
18. Source Repository, License & Contributing#
Released under the MIT License. All assemblies follow EricksonLopez.* build invariants: explicit imports, strong-name signing (`EricksonLopez.snk`), and ASCII author metadata (`Erickson Lopez`).
19. Troubleshooting, Pitfalls & Migration Guidance#
- Core, Dapper, PostgreSQL, MySQL, MariaDB, and SQLite packages are Full AOT; Oracle and SqlServer provider packages set IsAotCompatible=false.
- Version lag detected: NuGet.org latest published version is v2.0.0, while local repository HEAD is at v3.1.0.
20. Quality & Verification Evidence#
- Strong-Name Signing (`EricksonLopez.snk`)
- EricksonLopez.snk
- `ImplicitUsings=disable`
- disable
- XML Documentation Extraction
- Verified (24 namespaces, 149 types, 748 members)
- MSBuild AOT / Trim Attributes
- 13 Full / 0 Partial / 2 Incompatible / 1 N/A
- BenchmarkDotNet Artifacts
- 0 total (0 measured, 0 na_error)
Explicit Verification Boundaries & Limitations
- All verified measurements below come strictly from `BenchmarkDotNet.Artifacts` running on .NET RyuJIT (0 NativeAOT benchmark runs exist in this snapshot).
- 1 unpublished