There is an answer here to explain how to do transactions with Entity Framework However the solution does not work with code first. I have experimented and my tests indicate the following does work
using (var scope = new TransactionScope())
{
DBContext1.SaveChanges()
If (ForceFailure) return 0 // used in testing
DBContext2.SaveChanges()
scope.Complete();
}
However I feel nervous because I am no longer passing parameters to SaveChanges or calling AcceptAllChanges
How do I establish whether I can trust my solution?