title: Why is RemoveRange not clearing DbSet?
body: <p>I have the following extension method for clearing <code>DbSet&lt;T&gt;</code>:</p>
  
  <pre><code>public static void Clear&lt;T&gt;(this DbSet&lt;T&gt; dbSet)
  {
      dbSet.RemoveRange(dbSet);
  }
  </code></pre>
  
  <p>And the usage looks like this:</p>
  
  <pre><code>databaseContext.Users.Clear();
  databaseContext.SaveChanges();
  </code></pre>
  
  <p>Now the question: why is the code not working, why is the table Users not empty?</p>
  
  <h2>EDIT</h2>
  
  <p>The correct answer is that <code>SaveChanges</code> throws an exception because of mutual entity relations and so some entities are not removed. I failed to notice the exception because it ran as a cleanup of a [integration] MSTest suite with all tests passing. But still, my original implementation did contain another mistake so I'm marking one of the responses pointing it out as <strong>the</strong> response.</p>