EricksonLopez.MultiTenancy

dotnet-multitenancy · Multi-Tenancy & Security

On this page (20 sections)

1. Identity, Tier & Maturity Profile#

L2 Cross-Cutting & ReliabilityStableMaintenance: MaintainedAOT: PartialMIT LicenseConfidence: HIGH
ApplicationInfrastructureCross-Cuttingnet8.0net9.0net10.0

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
Also published in this family:
EricksonLopez.MultiTenancy.AbstractionsEricksonLopez.MultiTenancy.AspNetCoreEricksonLopez.MultiTenancy.ConfigurationEricksonLopez.MultiTenancy.AuthenticationEricksonLopez.MultiTenancy.SqliteEricksonLopez.MultiTenancy.Dapper

4. Verified Ecosystem Metrics#

v2.0.0
NuGet Published Version
v3.1.0
Repo HEAD Version
4,685
NuGet Downloads
16
Packable Packages
748
Public API Members
0
Benchmark Rows (RyuJIT)

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 IDStatusNuGet / LocalTFMsAOT StatusDownloadsDescription
EricksonLopez.MultiTenancyPrimaryPublishedv2.0.0 / v3.1.0net8.0, net9.0, net10.0AOT: Full347Core 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.AbstractionsPublishedv2.0.0 / v3.1.0net8.0, net9.0, net10.0AOT: Full675Foundation 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.AspNetCorePublishedv2.0.0 / v3.1.0net8.0, net9.0, net10.0AOT: Full308ASP.NET Core integration for multi-tenant SaaS applications: resolution middleware, endpoint filters and strategies (Header, Host, Claims, Route).
EricksonLopez.MultiTenancy.ConfigurationPublishedv2.0.0 / v3.1.0net8.0, net9.0, net10.0AOT: Full301Microsoft.Extensions.Configuration and Options integration for EricksonLopez.MultiTenancy, enabling dynamic tenant configuration loading from appsettings and configuration providers.
EricksonLopez.MultiTenancy.AuthenticationPublishedv2.0.0 / v3.1.0net8.0, net9.0, net10.0AOT: Full286ASP.NET Core authentication and cookie security integration for multi-tenant applications, preventing cross-tenant cookie hijacking and tenant hopping.
EricksonLopez.MultiTenancy.SqlitePublishedv2.0.0 / v3.1.0net8.0, net9.0, net10.0AOT: Full286SQLite 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.DapperPublishedv2.0.0 / v3.1.0net8.0, net9.0, net10.0AOT: Full285Dapper integration for multi-tenant applications: tenant parameter injection and connection string resolution.
EricksonLopez.MultiTenancy.PostgreSqlPublishedv2.0.0 / v3.1.0net8.0, net9.0, net10.0AOT: Full285PostgreSQL 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.SqlServerPublishedv2.0.0 / v3.1.0net8.0, net9.0, net10.0AOT: Incompatible284Microsoft 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.OraclePublishedv2.0.0 / v3.1.0net8.0, net9.0, net10.0AOT: Incompatible282Oracle 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.MariaDbPublishedv2.0.0 / v3.1.0net8.0, net9.0, net10.0AOT: Full280MariaDB 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.TestingPublishedv2.0.0 / v3.1.0net8.0, net9.0, net10.0AOT: Full277Testing helpers, test doubles, and fluent builders for EricksonLopez.MultiTenancy.
EricksonLopez.MultiTenancy.MySqlPublishedv2.0.0 / v3.1.0net8.0, net9.0, net10.0AOT: Full267MySQL 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.OpenTelemetryPublishedv2.0.0 / v3.1.0net8.0, net9.0, net10.0AOT: Full267OpenTelemetry distributed tracing, metrics, and W3C baggage propagation for EricksonLopez.MultiTenancy.
EricksonLopez.MultiTenancy.AnalyzersAnalyzer / GeneratorPublishedv2.0.0 / v3.1.0netstandard2.0AOT: N/A (Analyzer/Legacy)255Roslyn Analyzers for EricksonLopez.MultiTenancy lifecycle and invariant safety.
EricksonLopez.MultiTenancy.CachingUnpublished— / v3.1.0net8.0, net9.0, net10.0AOT: Full0Multi-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#

flowchart LR
  lib_multitenancy["EricksonLopez.MultiTenancy (L2)"]
  lib_result["EricksonLopez.Result (L0)"]
  lib_multitenancy --> lib_result
EricksonLopez.MultiTenancy Dependency Topology1 upstream library dependencies and 0 downstream dependent libraries verified in dependencies.json.
View accessible text summary and structure

1 upstream library dependencies and 0 downstream dependent libraries verified in dependencies.json.

DirectionLibraryTierRelationship Kinds
UpstreamEricksonLopez.ResultL0Compile-Time, NuGet Package
flowchart LR
  lib_multitenancy["EricksonLopez.MultiTenancy (L2)"]
  lib_result["EricksonLopez.Result (L0)"]
  lib_multitenancy --> lib_result

10. Target Frameworks & Native AOT / Trimming Matrix#

MSBuild `.csproj` inspection across 16 packages: 13 Full, 0 Partial, 2 Incompatible, 1 NotApplicable (analyzers/generators).

Package IDIsAotCompatibleEnableTrimAnalyzerVerified AOT StatusTarget Frameworks
EricksonLopez.MultiTenancytruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.MultiTenancy.AbstractionstruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.MultiTenancy.AspNetCoretruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.MultiTenancy.ConfigurationtruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.MultiTenancy.AuthenticationtruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.MultiTenancy.SqlitetruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.MultiTenancy.DappertruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.MultiTenancy.PostgreSqltruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.MultiTenancy.SqlServerfalsefalseIncompatiblenet8.0, net9.0, net10.0
EricksonLopez.MultiTenancy.OraclefalsefalseIncompatiblenet8.0, net9.0, net10.0
EricksonLopez.MultiTenancy.MariaDbtruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.MultiTenancy.TestingtruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.MultiTenancy.MySqltruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.MultiTenancy.OpenTelemetrytruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.MultiTenancy.AnalyzersfalsefalseNotApplicablenetstandard2.0
EricksonLopez.MultiTenancy.CachingtruetrueFullnet8.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)

DapperMicrosoft.CodeAnalysis.CSharpMicrosoft.CodeAnalysis.CSharp.WorkspacesMicrosoft.Data.SqlClientMicrosoft.Data.SqliteMicrosoft.Extensions.Caching.AbstractionsMicrosoft.Extensions.Configuration.AbstractionsMicrosoft.Extensions.DependencyInjection.AbstractionsMicrosoft.Extensions.Diagnostics.HealthChecks.AbstractionsMicrosoft.Extensions.OptionsMicrosoft.Extensions.Options.ConfigurationExtensionsMySqlConnectorNpgsqlOpenTelemetry.ApiOracle.ManagedDataAccess.CoreSQLitePCLRaw.bundle_e_sqlite3

13. Configuration & DI Registration Summary#

Verified DI & Configuration Entry Points

  • AspNetCoreMultiTenancyExtensions.AddAspNetCoreMultiTenancy

    Registers ASP.NET Core tenant resolution strategies and context accessor in the service collection.

  • AspNetCoreMultiTenancyExtensions.AddBasePathStrategy

    Registers a URL base path segment tenant resolution strategy in the service collection.

  • AspNetCoreMultiTenancyExtensions.AddDelegateTenantStrategy

    Registers a delegate-based tenant resolution strategy in the service collection.

  • AspNetCoreMultiTenancyExtensions.AddHostNameTenantStrategy

    Registers a host name and subdomain tenant resolution strategy in the service collection.

  • AspNetCoreMultiTenancyExtensions.AddInternalHeaderTenantResolution

    Registers a header-based tenant resolution strategy for internal service-to-service communication.

  • AspNetCoreMultiTenancyExtensions.AddMultiPlaneAspNetCore

    Registers multi-plane execution context services and ASP.NET Core anti-header-spoofing options.

  • AspNetCoreMultiTenancyExtensions.AddRouteTenantStrategy

    Registers a route-based tenant resolution strategy in the service collection.

  • AspNetCoreMultiTenancyExtensions.AddStaticTenantStrategy

    Registers a static tenant resolution strategy in the service collection.

  • AspNetCoreMultiTenancyExtensions.AddTenantRouteConstraint

    Registers the `Routing.TenantRouteConstraint` for use in ASP.NET Core routing.

  • AspNetCoreMultiTenancyExtensions.UseMultiPlaneContext

    Adds the `MultiPlaneContextMiddleware` to the application request pipeline to scrub untrusted headers and bind verified multi-plane principal claims.

  • AspNetCoreMultiTenancyExtensions.UseMultiTenancy

    Adds the `TenantResolutionMiddleware` to the application request pipeline.

  • InMemoryTenantStore<TTenant>.AddOrUpdate

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

VersionSourcePublished DateSummary
v2.0.0 ↗nuget2026-09-23Published EricksonLopez.MultiTenancy 2.0.0 to NuGet.org.
v2.0.0 ↗github2026-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 ↗github2026-08-27Ecosystem 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 ↗nuget2026-08-27Published EricksonLopez.MultiTenancy 1.0.0 to NuGet.org.

Libraries in the same tier, architectural layer, or directly paired via dependency edges.

17. Documentation, API Reference & Portal Links#

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

Search EricksonLopez.* Ecosystem

Type a library name, NuGet package ID, .NET type, or architectural concept to search across the portal.