-
Notifications
You must be signed in to change notification settings - Fork 226
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
TransactionScope Support #204
Comments
@thedumbtechguy I think part of the confusion is about .NET Core/.NET Standard 2.0 and EF Core 2.0. The current version of Npgsql already targets .NET Standard 2.0, so TransactionScope is fully supported there. As you said there's no support for distributed transactions with the DTC (because it's not cross-platform), but you can definitely use TransactionScope for ambient transactions etc. However, at the moment EF Core itself doesn't support TransactionScope as far as I can tell - the issue tracking this is dotnet/efcore#5595. You can ping the team on that issue to see what they're planning. IMHO it makes sense for EF Core 2.0 to add support since it will be released at the same time as .NET Standard 2.0, but it may be too late already. Hope that clears up your question, am going to close this as there's nothing to do on my side, but feel free to continue asking questions etc. |
I am not using EF. I am using Dapper. Also is there some warning mechanism in the event I accidentally promote my transactions like EF does when Enlisted scopes are used? |
Not at all, I only mentioned EF because you opened this issue on the Npgsql EF Core repo. If you're using Dapper you should be fine. As long as you're not trying to involve more than one database everything should work. |
Awesome! Thank you very much.
|
FYI new visitors, for TransactionScope to be working as expected make sure that "Enlist" key is set to true in PostgreSQL connection string (Enlist=True). |
For future reference, this is how you can use TransactionScope and EntityFramework together and Dapper. This is with Npgsql.EntityFrameworkCore.Postgresql 2.1.2 and Npgsql 4.0.3 I was actually able to get TransactionScope to work without having to use Enlist.
This is my DBContext and model. Notice I have this special method to use an existing connection.
|
So my foray into finding the answer for this has been difficult and fraught with many conflicting answers.
Will npgsql support transaction scopes in net core 2.0?
I know it's possible DTC won't be supported, but at least, will we get support for LTM?
I can write my code to not use multiple connections so if this is possible, it'll be really great.
NB: I don't even know the full extent for the support for TransactionScope in net core 2.0 so pardon me.
The text was updated successfully, but these errors were encountered: