Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7658903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:15:44+00:00 2026-05-31T13:15:44+00:00

In SQL one might sometimes write something like DELETE FROM table WHERE column IS

  • 0

In SQL one might sometimes write something like

DELETE FROM table WHERE column IS NULL

or

UPDATE table SET column1=value WHERE column2 IS NULL

or any other criterion that might apply to multiple rows.

As far as I can tell, the best EntityFramework can do is something like

foreach (var entity in db.Table.Where(row => row.Column == null))
    db.Table.Remove(entity);   // or entity.Column2 = value;
db.SaveChanges();

But of course that will retrieve all the entities, and then run a separate DELETE query for each. Surely that must be much slower if there are many entities that satisfy the criterion.

So, cut a long story short, is there any support in EntityFramework for updating or deleting multiple entities in a single query?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:15:45+00:00Added an answer on May 31, 2026 at 1:15 pm

    EF doesn’t have support for batch updates or deletes but you can simply do:

    db.Database.ExecuteSqlCommand("DELETE FROM ...", someParameter);
    

    Edit:

    People who really want to stick with LINQ queries sometimes use workaround where they first create select SQL query from LINQ query:

    string query = db.Table.Where(row => row.Column == null).ToString();
    

    and after that find the first occurrence of FROM and replace the beginning of the query with DELETE and execute result with ExecuteSqlCommand. The problem with this approach is that it works only in basic scenarios. It will not work with entity splitting or some inheritance mapping where you need to delete two or more records per entity.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might be an easy one, but I'm not really experienced with sql. I
In SQL one can write a query that searches for a name of a
Givens: One SQL Server is named: DevServerA Another is named: DevServerB\2K5 Problem: From DevServerA
I have sql statement one; select linkscat.id, linkscat.category from linkscat, contentlinks, links where contentlinks.linksid
I've moved database from one SQL Server instance on a machine to another machine
I need to pull data from one SQL 2005 Express database to another and
If I need to copy a stored procedure (SP) from one SQL Server to
I have a table like this id, name, datetime which might store multiple entries
I need to perform this SQL very frequently UPDATE Users SET UserPoint=UserPoint+(@UserPoint) WHERE UserID=@UserID
I have an SQL table called "posts" that looks like this: id | category

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.