title: Why is RemoveRange failing on entities already being tracked?
body: <p>After adding an entry using entities collection of DB context, if I try to call RemoveRange I get an InvalidOperationException.</p>
  
  <p>If I use another instance of the DB context to call RemoveRange, then it works fine. But when I use the same DB context, it fails.</p>
  
  <pre><code>var ingredient = new Ingredient()
  {
      Id = 1,
      Name = "Pepper",
  };
  await context.Ingredients.AddAsync(ingredient);
  await context.SaveChangesAsync();
  
  context.Ingredients.RemoveRange(context.Ingredients);
  await context.SaveChangesAsync();
  </code></pre>
  
  <p>The error message is :</p>
  
  <blockquote>
    <p>System.InvalidOperationException: The instance of entity type 'Ingredient' cannot be tracked because another instance with the key value '{IngredientId: 1}' is already being tracked. When attaching existing entities, ensure that only one entity instance with a given key value is attached.</p>
  </blockquote>
  
  <p>If I understood correctly, Remove() and RemoveRange() would attach the entity if it were not already tracked. In my case, an instance is already being tracked... true... but then, </p>
  
  <p><strong>what would be the correct way to remove all entries, without caring which entities are already tracked and which are not yet tracked ?</strong></p>
  
  <p>Any clue ?</p>