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 (3)

  1. Henrik Dahl says:


    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

  2. jitendra (indurotech.jp@gmail.com ) says:

    using(TransactionScope scope = new TransactionScope())


       // Your code

       scope.Complete(); //  To commit.


  3. fabson says:

    your sample that involves multiple datacontext will it work without MSDTC

Skip to main content