0
 bookingengineContext.IbeBookings.RemoveRange(bookingengineContext.IbeBookings);
 await bookingengineContext.SaveChangesAsync();

I did something like this but the table is not getting empty.

Svyatoslav Danyliv
  • 21,911
  • 3
  • 16
  • 32
Propsz
  • 1
  • 1
  • You can check some possible way to achieve this [here](https://stackoverflow.com/a/18986676/18101820). – Ivan Gechev Oct 04 '22 at 10:26
  • 1
    AFAIK this should delete everything, unless ne items where added after the enumeration has finished and there are no query filters added. You can try something like `bookingengineContext.IbeBookings.RemoveRange(bookingengineContext.IbeBookings.IgnoreQueryFilters())` but in general EF is not very suitable for bulk operations so you should consider using sql command for this (especially in this case it will fetch all data from the table into memory and then send back remove commands). – Guru Stron Oct 04 '22 at 10:52
  • That's not what EF and ORMs in general are for. If you want to delete all rows from a table execute `DELETE ThatTable`. ORMs as the name says Map Objects to Relational constructs. There are no objects or mapping involved here. – Panagiotis Kanavos Oct 04 '22 at 12:04

0 Answers0