Freigeben über


Entity Framework transaction scope examples

I just posted examples on how to use transaction scopes with entity framework on my programming interviews blog.

In this post, I cover three cases in which transaction scope is being used to show rollback when an error occurs during an update of multiple entities:

  1. when you have multiple save calls to the context;
  2. when you have single save with multiple object; and
  3. transactions across multiple contexts.

Check it out and share your feedback.

Comments

  • Anonymous
    June 07, 2012
    Hello! Couldn't you also try to show how to flow a transaction in and use it inside an asynchronous WCF activity, please? Best regards, Henrik Dahl

  • Anonymous
    February 07, 2013
    using(TransactionScope scope = new TransactionScope()) {    // Your code    scope.Complete(); //  To commit. }

  • Anonymous
    January 09, 2014
    your sample that involves multiple datacontext will it work without MSDTC