What\'s the best way to remove all elements in a System.Data.Entity.DbSet, with Entity Framework 4.3?
Here's another way you can do it in code.
public static class Extensions
{
public static void DeleteAll(this DbContext context)
where T : class
{
foreach (var p in context.Set())
{
context.Entry(p).State = EntityState.Deleted;
}
}
}
To actually call the method and clear the set:
myDbContext.DeleteAll();