c# Dotnettency Mutlitenancy library for dotnet applications.
Branch | Build Status |
---|---|
Master | |
Develop |
Branch | Dotnettency Core Library | Middleware | Container | EF Core |
---|---|---|---|---|
Master | ||||
Develop |
Branch | Autofac | StructureMap |
---|---|---|
Master | ||
Develop |
Inspired by saaskit
- Tutorial series here: http://darrelltunnell.net/tutorial/creating-modular-multi-tenant-asp-net-core-application-with-dotnettency/
- Various samples here: https://github.com/dazinator/Dotnettency.Samples
- More extensive sample app for a full display of all the current features or if you want to see MVC in action, checkout the MVC sample
- Tenant resolution
- Per Tenant Middleware Pipeline
- Per Tenant Containers
- Per Tenant HostingEnvironment
- Modules (Shared and Routed)
- Multitenant EF Core DbContext
Once configured in startup.cs
you can resolve the current tenant in any one of the following ways:
- Inject
TTenant
directly (may block whilst resolving current tenant). - Inject
Task<TTenant>
- Allows you toawait
the currentTenant
(so non blocking).Task<TTenant>
is convenient. - Inject
ITenantAccessor<TTenant>
. This is similar to injectingTask<Tenant>
in that it provides lazy access the current tenant in a non blocking way. For convenience it's now easier to just injectTask<Tenant>
instead, unless you want a more descriptive API.
The TenantShell
stores additional context for a Tenant, such as it's Container
and it's MiddlewarePipeline
.
- Inject
ITenantShellAccessor<TTenant>
in order to access context for the currnet tenant, which is primarily used by:- Extensions (such as Middleware, or Container) - which store things for the tenant in the
ITenantShellAccessor<TTenant>
's concurrent property bag. - Tenant Admin screens - if you need to "Restart" a tenant, then the idea is, you can resolve the
ITenantShellAccessor<TTenant>
and then use extension methods (provided by the dotnettency extensions such as Middleware pipeline, or Container) to allow you to control the state of the running tenant - for example to trigger rebuild of the tenant's container, or pipeline on the next request.
- Extensions (such as Middleware, or Container) - which store things for the tenant in the
Notes: For details on what Per Tenant Hosting Environment does see the README on the sample.