MultiTenant

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

MultiTenant is the core the other packages build on. It resolves the tenant from any context, tracks the current tenant, and lets the rest of your app vary by tenant through standard dependency injection and options.

Use it on its own in worker services, queue consumers, and console apps, or add the ASP.NET Core, Entity Framework Core, and Identity packages on top.

dotnet add package Finbuckle.MultiTenant
builder.Services.AddMultiTenant<AppTenantInfo, string>()
    .WithDelegateStrategy<QueueMessage, AppTenantInfo, string>(
        message => Task.FromResult<string?>(message.Tenant))
    .WithConfigurationStore();

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
v9.4.16 .NET 8 and 9 Nov 10, 2026 Release notes
v8.1.21 .NET 6, 7, and 8 Nov 10, 2026 Release notes

All versions on NuGet · All releases on GitHub

Model tenants your way

A tenant is any class that implements ITenantInfo. Start from TenantInfo and add the properties your app needs.

  • Choose the tenant ID type: string, int, Guid, or any equatable type.
  • Identifiers can change; IDs never do.
  • Keep tenant info small and load heavier data by tenant ID when you need it.
Read the core concepts
public class AppTenantInfo : TenantInfo<string>
{
    public string? Name { get; init; }
    public string? Theme { get; init; }
    public string? SupportEmail { get; init; }
}

builder.Services.AddMultiTenant<AppTenantInfo, string>();

Keep tenant details where they belong

Stores look up tenant details for the identifier a strategy found. Put a cache in front of any store to keep lookups fast.

  • Configuration, in-memory, HTTP remote, and echo stores, or write your own.
  • Distributed and in-memory caches, invalidated automatically when tenants change.
  • TenantManager for adding, updating, and removing tenants at runtime.
Explore stores
builder.Services.AddMultiTenant<AppTenantInfo, string>()
    // ...strategies
    .WithDistributedCacheStoreCache()
    .WithHttpRemoteStore("https://tenants.example.com/{__tenant__}");

Vary settings by tenant

Configure any options-pattern type per tenant. Components that already read options pick up the right values for the current tenant without changes.

  • PerTenant versions of Configure, ConfigureAll, and PostConfigure.
  • Named options and the OptionsBuilder API are supported.
  • Works with any options type, including ones from ASP.NET Core and third-party libraries.
Read about per-tenant options
builder.Services.ConfigurePerTenant<BrandingOptions, AppTenantInfo, string>(
    (options, tenant) =>
    {
        options.Theme = tenant.Theme;
        options.SupportEmail = tenant.SupportEmail;
    });

Run work as a tenant

Background services, queue consumers, and scheduled jobs can resolve a tenant and run work with that tenant's services and options.

  • Delegate strategies resolve a tenant from a message, job, or any object.
  • RunInTenantScopeAsync runs work in a fresh DI scope for a tenant.
  • The caller's own tenant scope is unchanged when the work finishes.
Read about .NET Generic Host support
await services.RunInTenantScopeAsync(tenantInfo, async scoped =>
{
    // resolved for this tenant, with its options
    var mailer = scoped.GetRequiredService<IInvoiceMailer>();
    await mailer.SendOverdueRemindersAsync();
});

The rest of the MultiTenant family

MultiTenant Abstractions

Finbuckle.MultiTenant.Abstractions

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

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