Finbuckle / Finbuckle.MultiTenant

Finbuckle.MultiTenant is an open-source multitenancy middleware library for .NET. It enables tenant resolution, per-tenant app behavior, and per-tenant data isolation.
https://www.finbuckle.com/multitenant
Apache License 2.0
1.26k stars 256 forks source link

Changing From MSSQL to PostreSQL Fails to Resolve Tenant #841

Open japhethmutai opened 3 weeks ago

japhethmutai commented 3 weeks ago

Hi @AndrewTriesToCode, I know this could be pretty simple setting on my end, but I have this rather weird behaviour. I developed a demo app with the package and initially used SQL for the database. Everything worked as expected, but when I tried to shift to NpSql, I experienced a behaviour that prevented me from using the app. I can generate migrations and apply them to the database successfully, including seeding the data to db. However, when I try to make a query from Swagger with the tenant Id added as query param, every time, it gives me the error of 'Object reference not set to an instance of an object.' because the tenant is null. I have tried finding out where the issue could be but I don't seem to resolve this problem. Here is the code for the project I am working with. Thank you in advance.

RobinDavisNotts commented 2 weeks ago

In AddInfrastructureServices you are calling AddMultitenancyServices before you call AddPersistenceService (which adds the IOptions for Database settings)

japhethmutai commented 2 weeks ago

In AddInfrastructureServices you are calling AddMultitenancyServices before you call AddPersistenceService (which adds the IOptions for Database settings)

Hi @RobinDavisNotts, I tried rearranging these as suggested but still hitting the same error. Seems this didn't work or what do you suggest?