Browse Source

add about ConfigurationTenantResolveContributor in multi-tenancy document

pull/23162/head
Suhaib Mousa 8 months ago
parent
commit
382c0d3595
  1. 36
      docs/en/framework/architecture/multi-tenancy/index.md

36
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<AbpTenantResolveOptions>(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:

Loading…
Cancel
Save