Ajay Bhasy
Ajay Bhasy

Reputation: 2000

Does Entity Framework handle transaction by default on ExecuteFunction while calling transactions?

ObjectContext.ExecuteFunction<GetStoredProcedure_Result>("StoredProcedure", parameter);

Does this code cover transaction automatically (by Entity Framework)? Or should I add transaction in the stored procedure as well?

Please provide any links.

Upvotes: 1

Views: 884

Answers (1)

PaulShovan
PaulShovan

Reputation: 2134

In EF6 every stored procedure call is wrapped in Transaction. But for the earlier versions of EF it will not cover automatically. You need to specify TransactionScope as following...

using (TransactionScope transaction = new TransactionScope())
{
   //your code here
}

For more on transaction follow MSDN.

I think this link and this link can help you in your case.

Upvotes: 1

Related Questions