Add TransactionMiddlewareMode for EF Core middleware#2160
Merged
jeremydmiller merged 1 commit intomainfrom Feb 10, 2026
Merged
Conversation
…eware. Closes GH-2086 Introduces Eager vs Lightweight mode to control whether EF Core transactional middleware opens an explicit database transaction or only relies on DbContext.SaveChangesAsync(). Eager remains the default for backwards compatibility. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This was referenced Feb 11, 2026
This was referenced Mar 1, 2026
This was referenced Mar 1, 2026
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
TransactionMiddlewareModeenum (Eager/Lightweight) to control whether EF Core transactional middleware opens an explicit database transaction or only relies onDbContext.SaveChangesAsync()UseEntityFrameworkCoreTransactions(TransactionMiddlewareMode)overload; existing no-arg version defaults toEagerfor backwards compatibility[Transactional(Mode = TransactionMiddlewareMode.Lightweight)]attribute property allows per-handler override of the global modeCloses #2086
Test plan
eager_mode_should_add_transaction_frame— verifies Eager addsEnrollDbContextInTransactionlightweight_mode_should_not_add_transaction_frame— verifies Lightweight skips transaction framedefault_mode_is_eager— verifies no-arg overload defaults to Eagertransactional_attribute_lightweight_overrides_eager_default— verifies attribute override from Eager→Lightweighttransactional_attribute_eager_overrides_lightweight_default— verifies attribute override from Lightweight→Eager🤖 Generated with Claude Code