2014年7月22日星期二

Entity Framework - Using Transactions or SaveChanges(false) and AcceptAllChanges()?

With the Entity Framework most of the time SaveChanges() is sufficient. This creates a transaction, or enlists in any ambient transaction, and does all the necessary work in that transaction.
Sometimes though the SaveChanges(false) + AcceptAllChanges() pairing is useful.
The most useful place for this is in situations where you want to do a distributed transaction across two different Contexts.