runtime icon indicating copy to clipboard operation
runtime copied to clipboard

Support System.Transactions in SqlClient for .NET Core

Open divega opened this issue 10 years ago • 7 comments

Given System.Transactions is going to be included in 1.2 (see https://github.com/dotnet/corefx/issues/2949) the next step seems to be to bring auto-enlistment of ambient transactions and related behaviors into the .NET Core version of SqlClient.

Note that the corresponding EF Core feature (tracked at https://github.com/aspnet/EntityFramework/issues/5595) will depend on this to work with SQL Server.

divega avatar Oct 10 '16 23:10 divega

Does SqlClient support some functionality such as EnlistTransaction for System.Transactions on .net core? There is a user reporting not able to use SqlConnection with System.Transactions on .net core. Please share current status and plan for supporting System.Transactions in SqlClient on .net core.

qizhanMS avatar Jun 14 '17 18:06 qizhanMS

The development of the feature is underway. Right now we don't support EnlistTransaction or any API related to System.Transactions in SqlClient.

saurabh500 avatar Jun 14 '17 18:06 saurabh500

OK. I can live without Ambient Transactions, but are you saying that we can't even use explicit Transactions? How are you supposed to do anything remotely serious with SQL without Transactions?

ghost avatar Jul 19 '17 14:07 ghost

@DRAirey1 you can use DbTransaction APIs with SqlClient to manage transactions. System.Transactions cannot be used with SqlClient in 4.4.0

@geleems can we close this issue now that you have pushed your changes for ambient transactions and related APIs?

saurabh500 avatar Jul 19 '17 15:07 saurabh500

How does this work with an n-Tier design? That is, how do I create a transaction that commits to my in-memory model and my persistent store (SQL Server) as an atomic action? I don't see how I do this with an SqlTransaction.

ghost avatar Jul 19 '17 15:07 ghost

Ambient Transaction and Transaction related APIs were ported from Framework: https://github.com/dotnet/corefx/pull/22059

geleems avatar Jul 19 '17 17:07 geleems

Yes. I see the Transactions. Yes. I see the SqlClient library. No, I can't get them to work together like they do in .NET Framework 4.7. I get 'Enlisting in Ambient transactions is not supported' when I try to execute EnlistTransaction().

I don't need Ambient Transactions, but I need some mechanism to make sure that my in-memory update and my SQL update are committed as a unit. If there's some new library or paradigm, I'm happy to look at it.

ghost avatar Jul 19 '17 17:07 ghost