Skip to content

GH-5297 IDocumentStoreDiagnostics for EF Core DbContexts - #5302

Merged
jeremydmiller merged 1 commit into
mainfrom
stoat/critterwatch-1-2/wolverine-efcore-diagnostics
Oct 31, 2026
Merged

jeremydmiller merged 1 commit into
mainfrom
stoat/critterwatch-1-2/wolverine-efcore-diagnostics

Conversation

@jeremydmiller

Copy link
Copy Markdown
Member

Fixes #5297

Adds DbContextDocumentStoreDiagnostics<T> (registered next to each DbContextUsageSource, subject efcore://{Context}), so a tool can browse a DbContext's entities through IDocumentStoreDiagnostics.

  • Reads only. Set<T>().AsNoTracking() + ApplyCriteriaTo; translation failures become DocumentCriteriaNotSupportedException. Ordered by primary key when no ordering is given. Load by single-column key; keyless/composite-key types are listed and pageable, load returns null, IdEquals is refused.
  • Scalar properties only, by property name; no navigations, no Include. Owned and shared-type entities aren't listed.
  • Wolverine's own entities: WolverineMappedEntities.IsWolverineEntity(...) identifies IncomingMessage/OutgoingMessage. DocumentTypeRef has no flag for it, so this is the helper.
  • Tenancy: multi-tenanted contexts are built through IDbContextBuilder<T> (conjoined pins the tenant so the query filter scopes it; database-per-tenant picks the tenant database). AllTenants is refused on those (honouring it on conjoined means IgnoreQueryFilters, which would bypass other filters too); AllTenants + TenantId throws ArgumentException.
  • Refused: OrderByMetadata, correlation/causation/last-modified filters (no such columns).
  • Explain: returns the SQL EF Core generates for the page (ToQueryString). A provider-native plan was not done: ToQueryString leaves parameters unbound, so it can't be fed to EXPLAIN as is. Left as a follow-up.
  • Query-filter soft deletes are the filter's business; IncludeSoftDeleted is not interpreted.

Tests: efcore_document_store_diagnostics (SQL Server, 12) and conjoined_document_store_diagnostics (Postgres conjoined, 5) pass locally.

🤖 Generated with Claude Code

Reads only: entity types, paged/filtered/ordered queries, load by key, and the generated SQL as the plan. Scalar properties only, never Include; conjoined and database-per-tenant go through the context builder, AllTenants is refused there; Wolverine's IncomingMessage/OutgoingMessage are identifiable via WolverineMappedEntities.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@jeremydmiller
jeremydmiller merged commit 5cfe058 into main Oct 31, 2026
49 checks passed
This was referenced Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement IDocumentStoreDiagnostics for EF Core DbContexts, so tools can browse and filter entity rows

1 participant