I have to insert data in multiple tables using entity framework so I want to use transection scope for that please guide me how to use transection with entity framework 6?
Loading
I have to insert data in multiple tables using entity framework so I want to use transection scope for that please guide me how to use transection with entity framework 6?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Manish Kumar ChoudharyPosted Feb 17, 2015, 11:40 PM
Hi Namit Kumar,
You can use tranj using following syntax-
using (var transaction = db.Database.BeginTransaction())
{
try
{
// TODO: Add insert logic here
db.SaveChanges();
transaction.Commit();
}
}
catch (Exception ex)
{
transaction.Rollback();
}
}
Or go through following article it will help you.
http://www.c-sharpcorner.com/UploadFile/ff2f08/working-with-transaction-in-entity-framework-6-0/