I have multi-tenant table structure whereas each table has
TenantId and I am using Dapper as the only ORM along with SimpleCRUD (helper sits on the top of
dapper). If possible (by default) I prefer every
Read Query MUST pass the
TenantId as a
parameter automatically, otherwise afraid there is a chance to forget.
Curious to know how others are solving this case? Are there any effective ways to solve this issue?
Dapper is a micro ORM and as far as I know it does not have this kind of feature.
In Entity Framework 6 you can use interceptors to force the query to filter by the TenantId.
In Entity Framework Core you can use QueryFilters.
In SqlServer you can use Row Level Security independently of the ORM.