/* hack to set the current DbTransaction onto the DbCommand. Transaction comes from EF private properties. */ public void SetCurrentTransaction(System.Data.Common.DbCommand command) { if (EntityTransaction != null) { // get private member via reflection var bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance; var etype = EntityTransaction.GetType(); var stProp = etype.GetProperty("StoreTransaction", bindingFlags); var transaction = stProp.GetValue(EntityTransaction, null); var dbTransaction = transaction as System.Data.Common.DbTransaction; if (dbTransaction != null) { command.Transaction = dbTransaction; } } }