title: Why does EF load data from the database and ignores local changes?
body: <p>I have the following code: </p>
  
  <pre><code>        var existingParticipant = Context.CaseParticipants.Where(p =&gt; p.CaseId == caseId);
          foreach (var cp in existingParticipant)
          {
              var ncp = caseParticipantList.First(a =&gt; a.Id == cp.Id);
              cp.IsIncompetent = ncp.IsIncompetent;
              cp.IsLeave = ncp.IsLeave;
              cp.SubstituteUserId = ncp.IsPresent ? null : ncp.SubstituteUserId;
          }
          var withSubs = existingParticipant.Where(c =&gt; c.SubstituteUserId != null).ToList();
  </code></pre>
  
  <p>What surprised me is that the last line fetches the rows from the DB a second time, ignoring any changes I've just done in the previous lines, why is that, and how do I avoid it? </p>