How I can quickly remove all rows in table using Entity Framework?
I am currently using:
var rows = from o in dataDb.Table
select o;
forea
Delete all records. Do not reset the primary index like "truncate".
///
/// SET - DELETE all record by table - no truncate - return deleted records
///
public static int setListDelAllMYTABLE()
{
// INIT
int retObj = 0;
using (MYDBEntities ctx = new MYDBEntities())
{
// GET - all record
var tempAllRecord = ctx.MYTABLE.ToList();
// RESET
ctx.MYTABLE.RemoveRange(tempAllRecord);
// SET - final save
retObj += ctx.SaveChanges();
}
// RET
return retObj;
}