abp icon indicating copy to clipboard operation
abp copied to clipboard

Create tenant with id

Open eneskoroglu opened this issue 4 years ago • 4 comments

I have multiple ABP projects. And I want to create same tenant under some of them with same id. When i look at tenantManager or tenantRepository, i cannot create a tenant with a specific id. How can i do this? Or can you change tenantId from protected to public or add a parameter to tenantManager.createAsync method for tenantId.

  • Your ABP Framework version. : 4.4.4

eneskoroglu avatar Jun 10 '22 08:06 eneskoroglu

And I want to create same tenant under some of them with same id

Why not make tenant management a separate application? you can share it in multiple projects.

realLiangshiwei avatar Jun 10 '22 09:06 realLiangshiwei

Hi realLiangshiwei

There is two scenarios:

  1. If i create all tenants (SassTenants data) on a seperate database, i will have problem to understand which records related to which tenant?
  2. If i create all tenants in every project, then every application gives different id to sameTenant and when i try to combine data for ex. on a datawarehouse, i cannot match data via tenantId for same tenant.

eneskoroglu avatar Jun 10 '22 11:06 eneskoroglu

All right.

i cannot create a tenant with a specific id. How can i do this?

This is by design, you can't do it

In fact, you don't need to create a tenant with the same id, since the Tenant entity is extensible, you can use the same business id, see: https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Extending-Entities#entity-extensions-ef-core

For example:

var tenant = TenantManager.CreateAsync("test");
tenant.SetProperty("BusinessId", Guid.NewGuid());

realLiangshiwei avatar Jun 10 '22 12:06 realLiangshiwei

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 11 '22 23:08 stale[bot]