Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EF Core DbTransaction - Undocumented IDisposable behaviour on Transactions #4973

Open
RiversJohn opened this issue Mar 10, 2025 · 2 comments

Comments

@RiversJohn
Copy link

Type of issue

Missing information

Description

I tried looking for documentation on what the behaviour of a transaction is when it goes out of scope in the following scenarios:

  • When commit is called but the action fails, e.g. illegal transaction and throws an exception
  • Commit is never called and the transaction simply goes out of scope
  • I've assumed that the transaction failing and being disposed results in some kind of implicit RollBackAsync behaviour
  • Additionally the usages of RollbackAsync aren't particularly clear

Page URL

https://learn.microsoft.com/en-us/ef/core/saving/transactions

Content source URL

https://github.com/dotnet/EntityFramework.Docs/blob/main/entity-framework/core/saving/transactions.md

Document Version Independent Id

cf56babd-def0-d76e-8eee-e33341b6a009

Article author

@roji

@RiversJohn
Copy link
Author

Feel free to ask for more details or rewording if anything is unclear

@roji
Copy link
Member

roji commented Mar 10, 2025

When commit is called but the action fails, e.g. illegal transaction and throws an exception

Commit() will throw an exception at that point, and the transaction will be rolled back.

Commit is never called and the transaction simply goes out of scope

The transaction is automatically rolled back.

I've assumed that the transaction failing and being disposed results in some kind of implicit RollBackAsync behaviour

Yes.

Additionally the usages of RollbackAsync aren't particularly clear

You'll have to be more specific.

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

No branches or pull requests

2 participants