ABP Zero Multi-tenant management

Source: Internet
Author: User

Abpzero-Multi-tenant management

Enable multi-tenancy

The ASP. Boilerplate and Module-zero can run multi-tenant or single-tenant mode. Multi-tenancy is disabled by default. We can enable it in our module Preinitialize method to make it as follows:
[DependsOn (typeof (Abpzerocoremodule))]
public class Mycoremodule:abpmodule
{
public override void Preinitialize ()
{
Configuration.MultiTenancy.IsEnabled = true;
}

...
}
It is important to note that even if our application is not multi-tenancy, we must define a default tenant (see the default tenant section of this file).
When we create a project template based on ASP. Boilerplate and Module-zero, we have a tenant's entity and Tenantmanager Domain Services.

Tenant Entity

The tenant entity represents a tenant for the application.
public class Tenant:abptenant<tenant, user>
{

}
It originates from the generic class abptenant. The tenant entity is stored in the Abptenants table of the database. You can add custom attributes to the tenant class.
The Abptenant class defines some basic properties, and most importantly:
Tenancyname: This is the unique name of a tenant in the application. It should not normally be changed. It can be used to assign subdomains to tenants such as "mytenant.mydomain.com".
Tenant.tenancynameregex constants define naming conventions.
Name: An arbitrary, human-readable, long-name tenant.
Isactive:true, this tenant can use the application. If it is false, no user can log on to the system for this tenant.
The Abptenant class is inherited from Fullauditedentity. This means that it has the create, modify, and delete audit properties. This is also soft delete. So when we delete the tenant, it is not deleted from the database, just marked for deletion.
Finally, the ID of the abptenant is defined as int.
Tenant Manager

Tenant Manager is a service that tenants perform domain logic for:
public class Tenantmanager:abptenantmanager<tenant, Role, user>
{
Public Tenantmanager (irepository<tenant> tenantrepository)
: Base (Tenantrepository)
{

}
}
You can add your own method here. You can also overwrite any method of the Abptenantmanager base class against your own needs.
Default Tenant

The ASP. Boilerplate and Module-zero assume that there is a pre-defined tenant whose tenancyname is "Default" and the ID is 1. In a single-tenant application, this is used as a single tenant. In a multi-tenant application, you can delete it or invalidate it.

ABP Zero Multi-tenant management

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.