title: How to delete a list of objects in EF6 when the object is detached from the context
body: <p>OK I can delete a single item in EF6 like this:</p>
  
  <pre><code>public void DeleteUserGroup(MY_GROUPS ug)
  {
      using (var context = new MYConn())
      {
          var entry = context.Entry(ug);
          if (entry.State == EntityState.Detached)
          {
              context.MY_GROUPS.Attach(ug);
          }
  
          context.MY_GROUPS.Remove(ug);
          context.SaveChanges();
      }
  }
  </code></pre>
  
  <p>If this method changed from passing a single instance of <code>MY_GROUPS</code> to a <code>List&lt;MY_GROUPS&gt;</code> how would I handle the delete?</p>
  
  <p>Would there be a more efficient way then just doing a <code>foreach</code> and setting the state one at a time?</p>
  
  <p><strong>UPDATE</strong>:
  I am already using a similar method as above utilizing the <code>RemoveRange</code> method.
  However I am getting an error:  </p>
  
  <blockquote>
    <p>The object cannot be deleted because it was not found in the
    ObjectStateManager.</p>
  </blockquote>
  
  <p>I'm looking for the best way to attach a list of objects to the context so that I can delete them.</p>