Athenex.Whimclean.Multitenancy.Abstractions 2.0.0

Prefix Reserved
dotnet add package Athenex.Whimclean.Multitenancy.Abstractions --version 2.0.0
                    
NuGet\Install-Package Athenex.Whimclean.Multitenancy.Abstractions -Version 2.0.0
                    
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="Athenex.Whimclean.Multitenancy.Abstractions" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Athenex.Whimclean.Multitenancy.Abstractions" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Athenex.Whimclean.Multitenancy.Abstractions" />
                    
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 Athenex.Whimclean.Multitenancy.Abstractions --version 2.0.0
                    
#r "nuget: Athenex.Whimclean.Multitenancy.Abstractions, 2.0.0"
                    
#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 Athenex.Whimclean.Multitenancy.Abstractions@2.0.0
                    
#: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=Athenex.Whimclean.Multitenancy.Abstractions&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Athenex.Whimclean.Multitenancy.Abstractions&version=2.0.0
                    
Install as a Cake Tool

Athenex.Whimclean.Multitenancy.Abstractions

ภาษาไทย

Dependency-free contracts for optional multitenancy. The consuming application owns tenant management; this package defines only integration boundaries. All types live in the Athenex.Whimclean.Multitenancy namespace.

Install

dotnet add package Athenex.Whimclean.Multitenancy.Abstractions

Most applications install an EF or ASP.NET Core multitenancy adapter instead and receive this package transitively.

Mark tenant-owned entities

using Athenex.Whimclean.Multitenancy;

public sealed class Order : IMultiTenant<Guid>
{
    public Guid Id { get; init; }
    public Guid TenantId { get; init; }
}

IMultiTenant<TTenantId> indicates data ownership through a read-only TenantId. The optional EF adapter uses it for query filtering and write validation.

Requested tenant versus current tenant

  • IRequestedTenant<TTenantId> represents an untrusted tenant selected by a header, route, host, or similar request input.
  • ICurrentTenant<TTenantId> represents the tenant established only after authorization.

Both expose TryGetTenantId(out TTenantId tenantId), which returns false when no tenant is present. Keeping these contracts separate prevents request input from automatically becoming an authorized data boundary.

AmbientCurrentTenant<TTenantId> is an ICurrentTenant<TTenantId> backed by an async-local scope for hosts without HTTP tenant resolution, such as background workers or seeders: wrap tenant-scoped work in using (AmbientCurrentTenant<Guid>.Begin(tenantId)). Scopes nest, disposing restores the previous tenant, and the caller vouches for the tenant because no access validation happens there.

Consumer-owned access validation

Implement ITenantAccessValidator<TUserId, TTenantId> against the application’s own membership storage and rules:

public sealed class TenantMembershipAccessValidator(
    AuthenticationDbContext dbContext)
    : ITenantAccessValidator<Guid, Guid>
{
    public Task<bool> HasAccessAsync(
        Guid userId,
        Guid tenantId,
        CancellationToken cancellationToken = default) =>
        dbContext.TenantMemberships.AnyAsync(
            membership =>
                membership.UserId == userId &&
                membership.TenantId == tenantId &&
                membership.IsActive,
            cancellationToken);
}

Implementations should fail closed and return false for unknown users or tenants. The consumer owns:

  • Tenant and TenantMembership entities
  • tenant creation, suspension, and deletion
  • membership invitation, roles, state, and expiry
  • subscription or entitlement rules
  • administrative cross-tenant authorization

The package also defines CurrentTenantRequiredException (tenant-owned changes are about to be persisted without an established current tenant) and TenantAccessViolationException (a save would change a record owned by another tenant) for fail-closed persistence boundaries.

This package has no Domain, Application, EF Core, ASP.NET Core, Identity, or database-provider dependency.

Repository and full architecture guide: https://github.com/athene-x/Whimclean

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.
  • net10.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Athenex.Whimclean.Multitenancy.Abstractions:

Package Downloads
Athenex.Whimclean.Infrastructure.EntityFrameworkCore.Multitenancy

Optional provider-neutral EF Core multitenancy enforcement with fail-closed query filters and write validation.

Athenex.Whimclean.Api.AspNetCore.Multitenancy

Framework-neutral ASP.NET Core multitenancy integration with requested-tenant resolution, membership authorization, authorized tenant context, and API error mapping; works with FastEndpoints or Minimal APIs.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 112 11/17/2026

2.0.0: first nuget.org release. Dependency-free requested and current tenant, tenant ownership, access validation and boundary exception contracts.