title: EF: How do I call SaveChanges twice inside a transaction?
body: <p>Using Entity Framework (code first in my case), I have an operation that requires me  to call SaveChanges to update one object in the DB, and then SaveChanges again to update another object. (I need the first SaveChanges to resolve an issue where EF can't figure out which object to update first).</p>
  
  <p>I tried doing:</p>
  
  <pre><code>using (var transaction = new TransactionScope())
  {
      // Do something
  
      db.SaveChanges();
  
      // Do something else
  
      db.SaveChanges();
  
      tramsaction.Complete();
  }
  </code></pre>
  
  <p>When I run that, I get an exception at the second <code>SaveChanges</code> call, saying "the underlying provider failed on open". The inner exception says that MSDTC is not enabled on my machine.</p>
  
  <p>Now, I've seen posts elsewhere that describe how to enable MSDTC, but it seems that I would also need to enable network access, etc. This sounds like complete overkill here, since there are no other databases involved, let alone other servers. I don't want to do something that's going to make my whole application less secure (or slower).</p>
  
  <p>Surely there must be a more lightweight way of doing this (ideally without MSDTC)?!</p>