MultiTenant Abstractions

The shared contracts: tenant info, strategy, store, and tenant context interfaces, with no implementation dependencies.

MultiTenant Abstractions holds the interfaces and basic types every other MultiTenant package is built on: ITenantInfo and TenantInfo, IMultiTenantStrategy, IMultiTenantStore, ITenantContext, and the [MultiTenant] attribute.

Reference it from class libraries, domain projects, and extensions that need to talk about tenants without taking a dependency on the full MultiTenant implementation, ASP.NET Core, or EF Core.

dotnet add package Finbuckle.MultiTenant.Abstractions
using Finbuckle.MultiTenant.Abstractions;

public class AppTenantInfo : TenantInfo<string>
{
    public string? Name { get; init; }
}

Releases

Version Targets Released Release notes
v11.0.0New .NET 11 Nov 24, 2026 Release notes
v10.2.0 .NET 10 Nov 12, 2026 Release notes

All versions on NuGet · All releases on GitHub

Share one tenant model across projects

Define your tenant type once in a shared library. Web apps, workers, and tests all reference the same type without pulling in the rest of MultiTenant.

  • ITenantInfo<TId> and the TenantInfo<TId> base class.
  • Any equatable tenant ID type: string, int, Guid, and more.
  • No dependency on ASP.NET Core or EF Core.
Read the core concepts
// in Contoso.Tenancy.csproj, which references only
// Finbuckle.MultiTenant.Abstractions
public class AppTenantInfo : TenantInfo<Guid>
{
    public string? Name { get; init; }
    public string? Region { get; init; }
}

Mark entities in your domain project

The [MultiTenant] attribute lives in Abstractions, so domain and model projects can mark entities as multi-tenant without referencing EF Core.

  • Keep persistence concerns out of the domain layer.
  • MultiTenant EF Core picks the attribute up in the data project.
Read about multi-tenant entities
using Finbuckle.MultiTenant.Abstractions;

[MultiTenant]
public class Invoice
{
    public int Id { get; set; }
    public decimal Amount { get; set; }
}

Write your own strategies

Implement IMultiTenantStrategy to identify tenants from any source, and ship it in a library that only depends on Abstractions.

  • One method: return the tenant identifier for a context, or null.
  • Set a priority to control the order strategies run in.
  • Register it with WithStrategy in the app.
Read about custom strategies
public class ApiKeyStrategy : IMultiTenantStrategy
{
    public Task<string?> GetIdentifierAsync(object context) =>
        Task.FromResult(context is HttpContext http
            ? ApiKeys.LookupTenant(http.Request.Headers["X-Api-Key"])
            : null);
}

builder.Services.AddMultiTenant<AppTenantInfo, string>()
    .WithStrategy<ApiKeyStrategy>(ServiceLifetime.Singleton);

Write your own stores

Implement IMultiTenantStore to load tenants from a system MultiTenant doesn't cover, such as an existing customer database or an internal API.

  • Look up tenants by ID or identifier.
  • Optional add, update, and remove for runtime tenant management.
  • Register it with WithStore in the app.
Read about custom stores
public class CrmTenantStore(CrmClient crm)
    : IMultiTenantStore<AppTenantInfo, string>
{
    public Task<AppTenantInfo?> GetByIdentifierAsync(string identifier,
        CancellationToken cancellationToken = default) =>
        crm.FindAccountAsync(identifier, cancellationToken);

    // ...other members
}

builder.Services.AddMultiTenant<AppTenantInfo, string>()
    .WithStore<CrmTenantStore>(ServiceLifetime.Scoped);

The rest of the MultiTenant family

MultiTenant

Finbuckle.MultiTenant

The foundation: tenant resolution, tenant stores, per-tenant options, and running work as a tenant in any .NET app.

Learn more

MultiTenant for ASP.NET Core

Finbuckle.MultiTenant.AspNetCore

Middleware, request-based strategies, and per-tenant authentication for ASP.NET Core apps.

Learn more

MultiTenant for EF Core

Finbuckle.MultiTenant.EntityFrameworkCore

Per-tenant data isolation for EF Core, in a shared database, a database per tenant, or a mix of both.

Learn more

MultiTenant Identity

Finbuckle.MultiTenant.Identity.EntityFrameworkCore

Multi-tenant ASP.NET Core Identity: each tenant gets its own users, roles, and passkeys.

Learn more