Entity Framework. Delete all rows in table
Asked 07 September, 2021
Viewed 2.2K times
  • 62
Votes

How can I quickly remove all rows in the table using Entity Framework?

I am currently using:

var rows = from o in dataDb.Table
           select o;
foreach (var row in rows)
{
    dataDb.Table.Remove(row);
}
dataDb.SaveChanges();

However, it takes a long time to execute.

Are there any alternatives?

23 Answer