title: TransactionScope, EF DbContext, and Dirty Read
body: <p>I've been Googling for an answer for the past few hours, but haven't found an answer, so I'm hoping someone here can point me in the right direction.</p>
  
  <p>I am wondering how to do a dirty read with EF DbContext (Code-First) within a TransactionScope.  For example</p>
  
  <pre><code>DbContext context = new MyEntities();
  using(TransactionScope scope = new TransactionScope())
  {
      context.SomeTable.Add(someObject);
      context.SaveChanges();
  
      var objects = context.SomeTable.Where(...).Select(...); //times out here on the read, because the write above locks the tables
      //modify each object
      context.SaveChanges();
  
      scope.Complete(); //transaction is a success only if the entire batch succeeds
  }
  </code></pre>
  
  <p>I have tried wrapping the read call with the following:</p>
  
  <pre><code>using(TransactionScope scope2 = new TransactionScope(TransactionScopeOption.RequiresNew, new TransactionOptions{IsolationLEvel = IsolationLevel.ReadUncommitted}))
  {
      var objects = context.SomeTable.Where(...).Select(...); //times out here on the 
  }
  </code></pre>
  
  <p>What is the proper approach?</p>