Skip to content

Skip BeginTransactionAsync when transaction already exists on DbContext#2159

Merged
jeremydmiller merged 1 commit intomainfrom
GH-2107
Feb 10, 2026
Merged

Skip BeginTransactionAsync when transaction already exists on DbContext#2159
jeremydmiller merged 1 commit intomainfrom
GH-2107

Conversation

@jeremydmiller
Copy link
Member

Summary

  • Fix EnrollDbContextInTransaction to check Database.CurrentTransaction == null before calling BeginTransactionAsync(), preventing InvalidOperationException when a transaction already exists (e.g. from EnlistInOutboxAsync persisting outstanding messages). Closes EF Core: Transaction already exists error when middleware sends cascading messages #2107
  • Fix flaky saga timeout test to use explicit activity tracking with WaitForMessageToBeReceivedAt<SomeTimeout>

Test plan

  • EfCoreTests pass (111/112 non-multi-tenancy, 1 failure is pre-existing resource contention)
  • Verify with a repro scenario using OutgoingMessages + AutoApplyTransactions + EF Core

🤖 Generated with Claude Code

…xt. Closes GH-2107

Also fix saga timeout test to use explicit activity tracking.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

EF Core: Transaction already exists error when middleware sends cascading messages

1 participant