IT:AD:EF:HowTo:Use Transactions
Summary
Transaction's are really rarely the right solution when talking about EF.
But if really need oneā¦
Process
The following demonstrates opening a specific connection (you don't need to make a connection, and create a new DbContext with it).
var mydb = new MyEFDB();
mydb.Connection.Open();
var tran = mydb.Connection.BeginTransaction();
...
// (now you can mix you EF code with your TSQL code)
...
mydb.ExecuteStoreCommand("DELETE FROM MyTable WHERE ...");
...
foreach(var c in mydb.Customers)
c.Name=....
...
mydb.SaveChanges();
tran.Commit();
mydb.Connection.Close();