bulk delete in entity framework

c# entity-framework linq-to-sql

Question

I'd like to bulk delete records from a table using linq. There's a post that describes how to do it: Bulk-deleting in LINQ to Entities

var query = from c in ctx.Customers
            where c.SalesPerson.Email == "..."
            select c;

query.Delete();

But the function "Delete" doesn't exist in my var variable.
Furthermore, the function "SubmitChanges" doesn't exist on my context.

1
4
5/23/2017 11:59:58 AM

Accepted Answer

There is an interesting NuGet package that lets you do batch deletes and updates:

4
7/21/2012 1:23:43 PM

Popular Answer

There is no currently supported bulk delete baked into Entity Framework. Its actually one of the features being discussed on codeplex now EF is open-source.

EntityFramework.Extended provides batch delete support (you can find this in nuget) however my experience is that it has some performance issues.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow