Open Closed

What is the correct way to implement multitenancy in Database per tenant model #1984


User avatar
0
LW created

Hello,
this https://docs.abp.io/en/abp/latest/Multi-Tenancy#imultitenant is not very clear on how should we do multitenancy in "Database per tenant" environment. If we know that we are not going to share our data accross tenants, can we disable multitenancy all together? If not, should only the aggregates be multitenant or entities under aggregates as well? This came up in a situation where we had both an aggregate and it's entity defined as IMultitenant but our logic only set the aggregate's tenant id in creation. This created a situation where aggregate's GetAsync, sub collection included, never populated the subcollection. Removin the IMultitenant defintion fron the entity fixed this. This got us thinkin do we still need to define aggregates and entities as multitenant if we know that tenant data will always be separated in tenant specific database?


4 Answer(s)
  • User Avatar
    0
    alper created
    Support Team Director

    use IMultitenant when the entity is not being shared across the tenants.

  • User Avatar
    0
    LW created

    And we should always set the tenant Id as well?

  • User Avatar
    0
    alper created
    Support Team Director

    yes correct

  • User Avatar
    0
    alper created
    Support Team Director

    see an example https://github.com/abpframework/abp/blob/48c52625f4c4df007f04d5ac6368b07411aa7521/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Users/CmsUser.cs#L33

Made with ❤️ on ABP v9.1.0-preview. Updated on December 10, 2024, 06:38