I think I’ve found the root cause. Here’s my observation: In short, the GetDbContextAsync method determines which database connection to use based on the entity type that the repository is bound to. I misunderstood this behavior at first. In my setup, the detail entities don’t have a TenantId field, so the repositories created for those entities always operate on the host database.
Yes, I have a separate connection string for the tenant. I can see it in the TenantConnectionStrings table, and its name is Default. I’ll clear the Redis cache and try again.
It’s a bit difficult for me to prepare a minimal reproduction project at the moment. Are there any specific areas or configurations you would recommend me to check?
var _ = await dbContext.Set<xxx>() .AsNoTracking() .Where(x => x.Code == xxx) .SingleAsync();
Because it runs on the host database, it can’t find the record.
I’m not directly using that connection string, but the queries I run through the DbContext are executed on the host database. Should I avoid using it as well?
It worked, thank you.
Hi,
No, I use Basic Theme
Can you share an example for method 2?
Ok I see, I didn't realize that endpoint was there. I guess I could use that. Thanks for your help.
Because I am sending a request from the API to change the settings. (/api/account-admin/settings/external-provider)