I am using the multitenancy feature of the framework. Each tenant has its own database. The problem is, When I run query in my Hangfire Job class, It always getting data from the base database.
By the way, I am require to use unitofwork in able to fetch data without conflict with the tenant.
Example code below:
using (var unitOfWork = _unitOfWorkManager.Begin()) { _unitOfWorkManager.Current.DisableFilter(AbpDataFilters.MayHaveTenant, AbpDataFilters.MustHaveTenant);...
...
Queries outside of that unitofwork will not work because of tenant conlict errors. Though I am able to get data now in my Hangfire Job class, the data came from the base or parent database not in my subtenant database.
Can someone help?
1 Answer(s)
-
0
Hi,
If you disable MayHaveTenant filter, your queries will be executed in Main (Host) database. You need to switch to specific tenant and then your queries will be executed in tenant's database. You can check https://aspnetboilerplate.com/Pages/Documents/Multi-Tenancy#switching-between-host-and-tenants.