Add lightweight EF Core tenant guardrails sample - #24
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a minimal .NET 10 companion sample for the EF Core 8 Multi-Tenancy: Tenant Isolation, Soft Deletes, Audit Trails & Query Filters tutorial.
The tutorial is EF Core 8-era and broad; this companion is EF Core 10 and narrowly answers: how can EF Core make shared-table tenant reads fail closed, keep soft-delete bypass tenant-safe, reject cross-tenant writes, and prove those guardrails against one relational database containing multiple tenants at the same time?
What's included
New sample:
ef-core/multitenancy-softdelete-auditing/— 13 filesTenantExecutionContextinjected into every DbContextTenantFilter(always active)SoftDeleteFilterwith selective bypass that keeps the tenant filter activeTenantId + Idso alpha/1 and beta/1 coexistSaveChangesInterceptor(sync + async) that overwrites insert tenant, rejects cross-tenant mutations, stamps creation/update audit, and convertsRemove()to a narrow soft-delete updateRoot README: New sample row in the table + updated repository structure tree
GitHub Actions: New
test-ef-core-tenant-guardrailsjob in the shared workflow; path filters updated for push and pull_requestDeliberately omitted (stays in the full tutorial)
HTTP tenant resolution, subdomain parsing, JWT/authentication, tenant membership lookup, platform-admin all-tenant access, background jobs, hard delete, GDPR workflows, PostgreSQL RLS / SQL Server security policies, migrations, compiled queries, ExecuteUpdate/ExecuteDelete, Minimal APIs, repositories, Testcontainers, benchmarks.
Versions
Validation
dotnet restore— passeddotnet build --configuration Release— passed (0 errors, 0 warnings)dotnet test --configuration Release— passed (8/8)