Nick Vaccaro
Nick Vaccaro

Reputation: 5504

Deleting Rows in a Database Table

What's the easiest way to delete rows in a database table using Entity Framework 6?

I just pulled down EF6 via NuGet and have been able to successfully query rows from the DB. However, I do not seem to have access to the context.<entity>.Delete() or context.<entity>.DeleteObject() methods, which are most often shown as examples online.

Upvotes: 0

Views: 190

Answers (1)

Nick Vaccaro
Nick Vaccaro

Reputation: 5504

Got it working.

var query = <linq query>;

context.<entity>.RemoveRange(query);
context.SaveChanges();

Upvotes: 1

Related Questions