I've just released an open-source .NET library: ModelHub.MultiTenancy π
Every multi-tenant SaaS has the same lurking bug: one query without a tenant filter, and one customer can see another customer's data.
While building StrideWell on my own (close to 100 database tables and 600+ API endpoints), I couldn't rely on remembering that filter every time. So I built the protection into the data layer:
β
The tenant comes from the user's login token
β
Every database query is filtered to that tenant automatically
β
Saves that would touch another tenant's data are refused
β
Branch-level access (a receptionist sees their own clinic only)
β
Support staff can act as a customer, with every access logged
Today I extracted it, tested it on .NET 8 and .NET 10, and published it on NuGet under ModelHub Solutions.
The write-up walks through a worked example of a vet practice SaaS. Link in the comments π
If you build multi-tenant apps in .NET, I'd really value your feedback, and contributions are welcome.β¦