Is it possible to share one connection (and transaction as well) between operations made in EF6 DB First approach and some ADO operations?
As I read here: https://msdn.microsoft.com/en-us/data/dn456843.aspx#existing it is possible to share connection and transactions since EF v6, but I have to pass SqlConnection object as a parameter to the constructor of context class. But if I do that in DB First approach , I've got UnintentionalCodeFirstException.
As I read here: https://msdn.microsoft.com/en-us/data/jj592674 I have to use instance of EntityConnection as a parameter to the constructor of context class when DB First approach is used. But EntityConnection class constructor accept only CLOSED connections. And therefore I cannot share transaction, because connection has to be closed before passed to context class.
Am I right and it is impossible to share one connection in this scenario, or maybe there is some other way?
Is TransactionScope still the only way to wrap operations in EF 6 DB First and ADO in a transaction (with separate connections) ?
I can not remember where I did get this from, but it helped me with running
EF
andSqlBulkCopy
in same transaction. Here is how to grab transaction with reflection fromEntity Framework
: