Base solution for your next web application
Open Closed

Cross-Tenant Operations and Host vs. Tenant vs. Both #10492


User avatar
0
SelfSwapAdmin created

ASP.NET Zero 10.2 Angular 10/.NET Core 5

I am using the "Load Entity from Database" feature in Power Tools to do a database-first implementation. It is going well but now I need to do something fairly tricky related to cross-tenant transactions. I need to be able debit any tenant's Account table with an amount and credit any other tenant's Account table with that amount. There are no predetermined and fixed relationships between any tenants. They cannot be assigned to a mutually exclusive organization. We are using a single database for now if not indefinitely. I like my service method being called from Tenant A to be able to insert rows into Tenant B's Account. The Account table is actually just a transation log of debits and credits, normally within a Tenant. For this one feature of our app we need to interact between tenants.

I am the process of prototyping this code now. Do you have a recommended approach for this? I am curious why the "Multi Tenancy" box in Power Tools allows the selection of "Host" or of "Tenant" or of both "Host" and "Tenant". What is the significance of that? What does that accomplish? I am currently using both "Host" only and "Tenant" only in my app.


1 Answer(s)
  • User Avatar
    0
    musa.demir created

    Hi @SelfSwapAdmin

    Power Tools' multitenancy selection indicates who can access the entity. It can be host side entity, tenant side entity or host and tenant side entiy which will be used by all host and tenant.

    You can change current session info in a scope to work like that another tenant. See: https://aspnetboilerplate.com/Pages/Documents/Abp-Session#overriding-current-session-values