Open mdshaner opened 3 years ago
However, I do not know how to start with writing a test case due to needing at least two databases setup for the multitenancy scenario to make sense.
Yeah we don't have true multi-tenancy tests. Current tests just use MS SqlServer AppName feature. See https://github.com/nhibernate/nhibernate-core/blob/master/src/NHibernate.Test/MultiTenancy/DatabaseStrategyNoDbSpecificFixture.cs
Isolated Work does not consider Tenancy when opening connection
This one is fixed in 5.3.9 with #2835
While working to migrate over to use the MultiTenancy Database strategy, I ran into a few problems rooted around the HiLoGenerator.
Shared HiLo Values
The TableHiLoGenerator's values are shared across all tenants. For my use case, this is actually not too difficult to work around with a custom Generator that uses a ConcurrentDictionary to isolate the values for each tenant. Honestly I'm only mentioning it because it's also the entry point that I encounter for the next issue.
Isolated Work does not consider Tenancy when opening connection
With a MultiTenancy (database) strategy, isolated scope work does not consume the Tenant configuration. It appears to be because in AdoNetTransactionFactory we get a connection by going to the factory without considering the Tenant. I have a local change that appears to work, but it also seems like it may be too heavy :
However, I do not know how to start with writing a test case due to needing at least two databases setup for the multitenancy scenario to make sense.