How to create a DBContext as part of an existing transaction in Entity Framework Core

ado.net c# entity-framework-core transactions

Question

I have product that already uses ADO.Net to access SQL Server and I'm using Entity Framework Core for some new functionality. The problem I'm having is I have some operations that must be done in a single transaction and the first few actions are implemented through ADO.Net and I need add an extra action using Entity Framework so I need to pass the transaction to the DBContext.

When I need to use an existing connection I can do:

var dbc = new MyDBContext(optionsBuilder.UseSqlServer(connection).Options)

Is there something similar where I pass in a transaction instead of a connection? Should I be doing this in a completely different way?

0
0
3/20/2018 1:56:25 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