title: Entity Framework and DbContext - Object Tracking
body: <p>I am a bit confused on the usage of DbContext in Entity Framework. Here's the scenario I'm confused about.</p>
  
  <ul>
  <li><p>I use a linq query from the dbcontext to get data. Something like:</p>
  
  <pre><code>List&lt;Transactions&gt; transactions = DefaultContext.Transactions.ToList();
  </code></pre></li>
  <li><p>Then I update a column in one of the transactions returned in that query directly in the database.</p></li>
  <li><p>Then I call again:</p>
  
  <pre><code>List&lt;Transactions&gt; transactions = DefaultContext.Transactions.ToList();
  </code></pre></li>
  </ul>
  
  <p>When the list returns back this time, it doesn't reflect the updates/changes I made when running the update statement, unless I loop through all my transactions and Reload them:</p>
  
  <pre><code>foreach (DbEntityEntry&lt;Transactions&gt; item in DefaultContext.ChangeTracker.Entries&lt;Transactions&gt;())
  {
      DefaultContext.Entry&lt;Transactions&gt;(item.Entity).Reload();
  }
  </code></pre>
  
  <p>Is this normal behavior? I assume that on my initial query, they are attached to the object context. Then when I query the second time, it doesn't make a trip to the database, and just pulls out the entities from the object context, unless I clear/detach or individually reload all of the entities.</p>