dotnet / dotnet/EntityFramework.Docs

Overview of EF Core and Transactions Does Not Discuss Async

Open
#3,250 4 comments 1 reaction 0 assignees View on GitHub
area-transactions
Dominant language
Mermaid
Stars
1.7k
Forks
2k
Avg merge
7d 23h
Merged PRs (30d)
16

Description

In EF Framework, when using transaction scopes with awaitable operations it was necessary to pass the `TransactionScopeAsyncFlowOption .Enabled` flag.

This removed the thread affinity of the scope, so should Task continations execute on a different thread everything would work. Because thread switches cannot be controlled _and_ tended not to happen in a development environment, this flag needed to be used even when under the debugger the exceptions would not be thrown.

In EF Core is this needed? Does `DbContext.Database.BeginTransaction()` handle the async case?

As async is the generally preferred approach it would really help if the documentation made it clear if this is not needed because many developers using EF Core will have learnt EF before Core was started let alone the current platform.

---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: 1073c238-9389-d826-a696-f1108a4f2ce0
* Version Independent ID: cf56babd-def0-d76e-8eee-e33341b6a009
* Content: [Transactions - EF Core](https://docs.microsoft.com/en-us/ef/core/saving/transactions)
* Content Source: [entity-framework/core/saving/transactions.md](https://github.com/dotnet/EntityFramework.Docs/blob/main/entity-framework/core/saving/transactions.md)
* Product: **entity-framework**
* Technology: **entity-framework-core**
* GitHub Login: @roji
* Microsoft Alias: **avickers**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.