seniorDependency Injection
How do you manage Tenant-specific configurations in DI without polluting business logic?
Updated Apr 28, 2026
Short answer
Tenant configuration should be injected via the Options pattern dynamically resolved per-request, keeping the tenant logic strictly out of the domain.
Deep explanation
The DI container resolves an ITenantContext (scoped) based on the HTTP header. Then, it configures an IOptionsSnapshot<TenantSettings> based on that context. The business logic simply asks for TenantSettings and remains oblivious to how the tenant was identified.
Unlock with a Pro subscription to view this section.
View pricingReal-world example
No real-world example available yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProCommon mistakes
No common mistakes listed yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProFollow-up questions
No follow-up questions available yet.
Unlock with a Pro subscription to view this section.
Upgrade to Pro