From 382c0d3595798332d6b4896b20a94d7087365076 Mon Sep 17 00:00:00 2001 From: Suhaib Mousa Date: Tue, 24 Jun 2025 00:43:07 +0300 Subject: [PATCH] add about ConfigurationTenantResolveContributor in multi-tenancy document --- .../architecture/multi-tenancy/index.md | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/docs/en/framework/architecture/multi-tenancy/index.md b/docs/en/framework/architecture/multi-tenancy/index.md index 0a035d110d..e216fac221 100644 --- a/docs/en/framework/architecture/multi-tenancy/index.md +++ b/docs/en/framework/architecture/multi-tenancy/index.md @@ -346,6 +346,42 @@ context.Services ``` +### `ConfigurationTenantResolveContributor` + +This tenant resolver reads the tenant identifier from application configuration `appsettings.json`. + +It is intended primarily for **development or testing environments** where setting the tenant manually is helpful, especially in **non-HTTP** contexts (e.g., console apps, background workers). + +##### **Configuration Example:** + +```json +{ + "MultiTenancy": { + "Tenant": "my-tenant-name" + } +} +``` + +The value can be either the **tenant name** or the **tenant ID**. + +###### **How to Use:** + +This resolver is not registered by default. You can add it manually in your module's `ConfigureServices`: + +```csharp +var env = context.Services.GetHostingEnvironment(); +if (env.IsDevelopment()) // Optional but preferred: only register in development +{ + Configure(options => + { + options.AddConfigurationTenantResolver(); + }); +} +``` + +> Recommended to limit this resolver to development to avoid static tenant resolution in production. + + ##### Custom Tenant Resolvers You can add implement your custom tenant resolver and configure the `AbpTenantResolveOptions` in your module's `ConfigureServices` method as like below: