title: Deleting an object with SQL and updating the Context
body: <p>I am using EF and have a context with which I have deleted a row in a table using a simple SQL call through the ExecuteStoreCommand function on the context (I have to do it this way for other reasons). It works fine, but the context doesn't know what happened.</p>
  
  <p>I get a problem later when using the same context when I'm trying to commit some changes because the commit does not give the expected number of affected rows.</p>
  
  <p>My question is, what is the best way to update the context with the changes (deleted rows) that I've made.</p>
  
  <p>I've already tried getting the deleted object and using it in the context refresh function, but it doesn't really work, probably because it (correctly) gets a null reference when trying to get the deleted object.</p>
  
  <pre><code>_ctx.Refresh(RefreshMode.StoreWins, _ctx.Employees.FirstOrDefault(s =&gt; s.EmployeeId == employeeId));
  </code></pre>
  
  <p>Also, using <code>ObjectStateManager.GetObjectStateEntries</code> doesn't work for me either, because it doesn't know which objects have been deleted.</p>
  
  <p>I do not want to:</p>
  
  <ul>
  <li>Recreate the context.</li>
  <li>Refresh more than I need to.</li>
  <li>Mess with lazy loading.</li>
  </ul>
  
  <p>I just want to get the context up to date again after deleting.</p>