Skip to content

Generated Code

The Tenancy module generates a TenantId TypedId. The middleware and options are hand-written runtime code.

TenantId TypedId

[TypedId(Profile = "tenant")]
public readonly partial struct TenantId;

Generates: - JSON converter for serialization - Implicit conversion from/to string - Value equality and comparison

DI Registration

Tenancy is registered as part of the runtime bootstrapper:

// Generated in Add{Runtime}()
services.Configure<TenancyOptions>(configuration.GetSection("Deepstaging:Tenancy"));

The TenantMiddleware is added to the ASP.NET Core pipeline separately:

app.UseTenantMiddleware();

What Is NOT Generated

Unlike most modules, Tenancy does not have an [EffectsModule]. The tenant context is propagated via CorrelationContext (ambient AsyncLocal), which every effect pipeline inherits automatically. See Effects Composition for how tenant flows through effect pipelines.