EntityFramework 6 has made this a bit easier with .RemoveRange()
.
Example:
db.People.RemoveRange(db.People.Where(x => x.State == "CA"));
db.SaveChanges();
More Related Contents:
- Code-first vs Model/Database-first [closed]
- Entity Framework: “Store update, insert, or delete statement affected an unexpected number of rows (0).” [closed]
- What’s the difference(s) between .ToList(), .AsEnumerable(), AsQueryable()?
- Disable lazy loading by default in Entity Framework 4
- Best way to check if object exists in Entity Framework? [closed]
- How to select top N rows for each group in a Entity Framework GroupBy with EF 3.1
- EF5 Code First Enums and Lookup Tables
- Entity Framework 4.1 DbContext Override SaveChanges to Audit Property Change
- Entity Framework One-To-One Mapping Issues
- How can I delete 1,000 rows with EF6?
- Entity Framework 4 selective lazy loading properties
- When should I call SaveChanges() when creating 1000’s of Entity Framework objects? (like during an import)
- Adding Validation Attributes With an Entity Framework Data Model
- How to exclude one table from automatic code first migrations in the Entity Framework?
- Ramifications of DbSet.Create versus new Entity()
- Entity Framework Code First – Advantages and disadvantages of Fluent Api vs Data Annotations [closed]
- Entity Framework : How do you refresh the model when the db changes?
- Entity framework code first creates “discriminator” column
- EF Migrations: Rollback last applied migration?
- Using EF Core ThenInclude() on Junction tables
- How to update not every fields of an object using Entity Framework and EntityState.Modified
- What is the best practice in EF Core for using parallel async calls with an Injected DbContext?
- EF Code First foreign key without navigation property
- LINQ to Entities for subtracting 2 dates
- Using the Entry().CurrentValues.SetValues() is not updating collections
- .NET 4.5 Beta DbGeography NotImplementedException
- Changing Inherited Types in Entity Framework
- Why is my Entity Framework Code First proxy collection null and why can’t I set it?
- An object with the same key already exists in the ObjectStateManager. The ObjectStateManager cannot track multiple objects with the same key
- Why does the entity framework need an ICollection for lazy loading?