Follow-up quality work on the bulk ExecuteUpdate/ExecuteDelete implementation delivered by EF-107 (#311).
A detailed review of the feature identified around fifty findings across correctness, data integrity, observability, performance, security posture and test coverage. Some were addressed during review of #311; the remainder are tracked here.
Highlights
Data integrity
- Setters can target provider-owned fields: the type discriminator (rewriting a document's type), the primary key (server-side immutable-_id failure surfaced as a raw driver exception), and concurrency tokens (silently disarming optimistic concurrency for later SaveChanges).
- BuildUpdate keys $set with GetElementName() while the serializer maps composite-primary-key parts to an _id.<name> path, so the two disagree about where a property lives.
- The self-referencing setter renderer rebinds parameters by type and documents — but does not enforce — a precondition that only one entity-typed parameter is present. Violating it renders a wrong update with no error.
Source classification
- Bare OrderBy/ThenBy/Distinct are classified as two-phase even though they cannot change which documents are affected. That needlessly requires a transaction-capable deployment, throws under AutoTransactionBehavior.Never, reads every matching document to the client, and makes the server perform a $sort that can fail outright on a large unindexed set.
- The classifier matches bare Method.Name rather than canonical QueryableMethods definitions, contrary to Query/AGENTS.md, so overloads with different semantics (indexed Where, Distinct(IEqualityComparer<T>), Take(Range)) are silently admitted.
- OfType/Cast are rejected although the read path supports them and they are the idiomatic way to scope a polymorphic query in this provider. Queryable.Order()/OrderDescending() are also unsupported.
Fail-closed gaps
- An ambient transaction that is not a MongoTransaction leaves both phases running with no session, silently losing the isolation that makes two-phase's _id-only second phase safe.
- Phase-1 translation failures escape TranslateBulkOrThrow, and because the transaction is opened first, an untranslatable query on a standalone deployment reports "this deployment does not support multi-document transactions".
- Async rollback is passed the caller's already-cancelled token, so on cancellation the transaction is never aborted client-side.
Performance — phase 1 fetches whole documents with no {_id: 1} projection (which also forecloses a covered index scan); the async path materialises every matched document before extracting ids, where the sync path streams; the $in list is unbounded against the 16 MB command limit.
Observability — the emitted command is never logged, so nothing can assert what was sent; two-phase elapsed excludes phase 1; ExecutedBulkUpdate reports only ModifiedCount and so cannot be reconciled with the value ExecuteUpdate returns; two event definitions of different arity share one EventId; MongoBulkWriteEventData.TargetCount is int? among long siblings.
Test coverage — no test covers global query filters with bulk operations (the soft-delete / multi-tenant case), and FiltersInheritanceBulkUpdatesTestBase remains excluded from compliance under a justification that does not apply to it. A pre-existing regression test for the allowed-queryable-extension gate was narrowed to EF8-only and its helper deleted. IsTransactionsUnsupported is untested despite a skipped test citing it as its coverage. No bulk coverage for TPH, encryption, cancellation, or the event payload.
Documentation — the README describes the single-command path as "a single atomic deleteMany/updateMany". MongoDB guarantees atomicity per document only, so that overstates the guarantee relative to the relational ExecuteDelete users are porting from.
Plan
A task-by-task implementation plan lives in the repository at docs/superpowers/plans/2026-07-30-ef-107-bulk-remediation.md, phased so that observability lands first (making the rest assertable), then data integrity, fail-closed correctness, classification, performance, coverage and docs.