How to get current transaction from the dbcontext

.net-core entity-framework-core

Question

In Entity Framework 6, under the DbContext class you can get to current transaction by context.Database.CurrentTransaction. However this API doesn't seem like available in EF.Core. How can I retrieve current transaction object from a dbcontext in EF.Core?

1
3
12/30/2016 4:49:48 PM

Accepted Answer

EF Core still lacks many EF6 features, but (slowly) is catching up.

In that regard, I can't say for earlier versions, but in the latest (so far ) v1.1.0 the DbContext.Database CurrentTransaction property is there, so you can use the same code as in EF6 to access it.

6
12/30/2016 7:37:51 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow