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

  • SEARCH
  • Home
  • 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 7993423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:50:47+00:00 2026-06-04T13:50:47+00:00

I recently noticed there is two different ways to delete an entry from the

  • 0

I recently noticed there is two different ways to delete an entry from the DB in Entity Framework.

I had originally implemented it using the following

db.Courses.Remove(course);

But then I found out that you can also do the following

db.Entry(course).State = EntityState.Deleted;

Is there any difference between the two?
The only reason I can think for me to switch to the latter would be to be more consistent in my implementation since that’s the approach I use to edit entries.

Any thoughts ?

  • 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-06-04T13:50:48+00:00Added an answer on June 4, 2026 at 1:50 pm

    Both methods mark the entity as deleted, so the next db.SaveChanges(); removes them from the database and the context.

    This article describes all ways you can add, modify and delete entities.

    http://msdn.microsoft.com/en-us/library/gg696174(v=vs.103).aspx

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

Sidebar

Related Questions

I noticed recently that there are two ways to print multiple statements in PHP.
Something that I've noticed recently on two different machines is that Apache2 installed via
I've noticed recently that there's a few java libs (the JDK, joda time, iText)
I recently moved to a project where I noticed there have a specific requirement
I have recently noticed that when i visit certain websites, there are usually links
I've been editing CSS using Firebug in Firefox, but recently noticed that Chrome is
I recently implemented a loading image and noticed that ever 10 seconds, that the
I recently noticed that I had a big hole in my application because I
I've recently noticed a couple concerning things when using the KO mapping plugin to
I'm using the Magento (1.6.2.0) XMLRPC-API to assign/remove products from a category. I recently

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.