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 8794269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:13:44+00:00 2026-06-13T23:13:44+00:00

I am using EF5 and I am getting an error when I am calling

  • 0

I am using EF5 and I am getting an error when I am calling context.SaveChanges in a for loop.

If I am updating any entity, do I need to call SaveChanges to get the updated value of the entity with in the same context.

For example,quantity of one line item is n. In my firts iteration I am reducing the quantity of line item by 1. So now the actual quantity is n-1. I have not yet called SaveChanges on context. In the next iteration for the same line item is the quantity would be n or n-1?

Thanks

  • 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-13T23:13:45+00:00Added an answer on June 13, 2026 at 11:13 pm

    I’m not quite sure what you are trying to do, but you definitely shouldn’t call SaveChanges in a loop. Make all the changes you need in a loop (add, remove or whatever on context), and when you’re finished, call SaveChanges.

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

Sidebar

Related Questions

I am working on a small project using C# and EF5.0 and I need
I ran into this error message while using EF5. Wondering if anyone has the
using VB.Net2010 I need to call a C# DLL The problem I have is
I have made a complex solution using EF5 (Lets call it EF5), this solution
What is the best way to deal with batch updates using (Entity Framework) EF5?
Using the Redis info command, I am able to get all the stats of
Using Location.getBearing(); I seem to get randomly changing bearings. Aka, I can turn the
I am using EF5 codefirst in an ASP.NET MVC4 app. I have products and
I am using EF5 code-first approach and I am just wondering should I detach
I'm using EF5 code first in a simple test application at the moment to

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.