It's strongly suggested to read multi tenancy documentation before this document.
ASP.NET Boilerplate and module-zero can run multi-tenant or single-tenant modes. Multi-tenancy is disabled by default. We can enable it in PreInitialize method of our module as shown below:
[DependsOn(typeof(AbpZeroCoreModule))]
public class MyCoreModule : AbpModule
{
public override void PreInitialize()
{
Configuration.MultiTenancy.IsEnabled = true;
}
...
}
Note that: Even our application is not multi-tenant, we must define a default tenant (see Default Tenant section of this document).
When we create a project template based on ASP.NET Boilerplate and module-zero, we have a Tenant entity and TenantManager domain service.
Tenant entity represents a Tenant of the application.
public class Tenant : AbpTenant<Tenant, User>
{
}
It's derived from generic AbpTenant class. Tenant entities are stored in AbpTenants table in the database. You can add your custom properties to Tenant class.
AbpTenant class defines some base properties, most importants are:
AbpTenant class is inherited from FullAuditedEntity. That means it has creation, modification and deletion audit properties. It's also Soft-Delete. So, when we delete a tenant, it's not deleted from database, just marked as deleted.
Finally, Id of AbpTenant is defined as int.
Tenant Manager is a service to perform domain logic for tenants:
public class TenantManager : AbpTenantManager<Tenant, Role, User>
{
public TenantManager(IRepository<Tenant> tenantRepository)
: base(tenantRepository)
{
}
}
You can add your own methods here. Also you can override any method of AbpTenantManager base class for your own needs.
ASP.NET Boilerplate and module-zero assumes that there is a pre-defined tenant which's TenancyName is 'Default' and Id is 1. In a single-tenant application, this is used as as the single tenant. In a multi-tenant application, you can delete it or make it passive.