You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TenantInfo null in AppDbContext, getting exception - Finbuckle.MultiTenant.MultiTenantException: 'MultiTenant Entity cannot be changed if TenantInfo is null.'
#846
Open
PiyushKumar19 opened this issue
Jun 25, 2024
· 1 comment
I'm trying to implement multi-tenancy by saving and fetching tenants from the database. For that, I created a custom store and registered it in the Program.cs . I've also injected IMultiTenantContextAccessor in AppDbContext.
When I try to make any request for an entity that has IsMultiTenant applied to it, the _multiTenantContextAccessor.MultiTenantContext.TenantInfo gets initialized as null in the AppDbContext constructor, which stays as null until the code execution passes through the Custom store from where it fetches the Tenant from the database (it stays null there also), TenantInfo gets Db fetched tenant data only after executing the Controller constructor.
It does not set the TenantInfo globally with the tenant data fetched from the Db from the custom store.
Please ignore those middlewares and ContextFactory classes, they're not being used anywhere.
The text was updated successfully, but these errors were encountered:
PiyushKumar19
changed the title
Finbuckle.MultiTenant.MultiTenantException: 'MultiTenant Entity cannot be changed if TenantInfo is null.'
TenantInfo null in AppDbContext, getting exception - Finbuckle.MultiTenant.MultiTenantException: 'MultiTenant Entity cannot be changed if TenantInfo is null.'
Jun 25, 2024
I'm trying to implement multi-tenancy by saving and fetching tenants from the database. For that, I created a custom store and registered it in the Program.cs . I've also injected IMultiTenantContextAccessor in AppDbContext.
When I try to make any request for an entity that has IsMultiTenant applied to it, the
_multiTenantContextAccessor.MultiTenantContext.TenantInfo
gets initialized as null in the AppDbContext constructor, which stays as null until the code execution passes through the Custom store from where it fetches the Tenant from the database (it stays null there also), TenantInfo gets Db fetched tenant data only after executing the Controller constructor.It does not set the TenantInfo globally with the tenant data fetched from the Db from the custom store.
Here's the repo link - https://github.com/PiyushKumar19/BuckleUp
Please ignore those middlewares and ContextFactory classes, they're not being used anywhere.
The text was updated successfully, but these errors were encountered: