简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM