Efcore: Enable support for System.Transactions

Created on 1 Jun 2016  路  5Comments  路  Source: dotnet/efcore

(Forked from https://github.com/aspnet/EntityFramework/issues/4147 which was mainly about fixing the misleading exception message we throw to indicate that we don't support System.Transactions)

By design we don't support System.Transactions (a.k.a. ambient transactions / TransactionScope and or CommitableTransaction) functionality in EF Core 1.0.0.

In full .NET framework connection objects such as SqlConnection will still auto-enlist on Open() or OpenAsync() but we have code in EF Core to detect the presence of an ambient transaction an throw.

The new ConfigureWarnings() API allows turning the error into a warning or to ignore it completely, but since EF Core will always just start a local transaction in the connection anyway (i.e. with BeginTransaction()) the feature is actually not usable.

This issue is about the possibility of getting out of the way from System.Transactions by conditionally skipping the creation of the local database transaction in full .NET or in any other platform that supports it e.g. when/if https://github.com/dotnet/corefx/issues/2949 is implemented.

closed-fixed punted-for-2.0 type-enhancement

Most helpful comment

Hi...is the use of TransactionScope with EntityFramework Core now supported?

All 5 comments

Progress has been made for the feature to be available in .NET Core 1.2, although SqlClient for .NET Core still doesn't do anything with ambient transactions (plus auto-enlistment never stopped working in .NET Framework).

Clearing up milestone and ownership so that we can decide what to do and who to assign it to in triage.

Please note that Npgsql already supports .NET Standard 2.0, and so has System.Transaction support as well. In other words, adding System.Transaction support to EF Core doesn't necessarily depend on SqlClient adding support.

Hi...is the use of TransactionScope with EntityFramework Core now supported?

Will we need aspnet/Microsoft.Data.Sqlite#294 for this?

We don't _need_ it, since this is mostly about the work in Relational. It will probably still throw for providers that don't explicitly support it.

Was this page helpful?
0 / 5 - 0 ratings