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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:14:02+00:00 2026-06-16T20:14:02+00:00

When calling AcceptChanges I get the following error: AcceptChanges cannot continue because the object’s

  • 0

When calling AcceptChanges I get the following error:

AcceptChanges cannot continue because the object’s key values conflict with another object in the ObjectStateManager. Make sure that the key values are unique before calling AcceptChanges.

Now I’ve searched the web for quite a bit, but didn’t find the answer I was looking for.

I know they made it by design so that you should prevent from adding an entity that already exists by using the ID instead of an entity object but I’m in a situation where i simply cannot do that.

I have an import and an export, which is generic, I can give any entity object and it will make it an xml format, and in reverse I can give any xml and get the right entity. I couldn’t use a serializer because I had to make the xml in a custom format.

The problem lies when I have deeper nested entities that could have been added to the main entity before already , I cannot check it on the spot so they get added. causing the problem that the same entity might get added multiple times.

And when I’m further ahead and I wish to apply changes, the error happens.

Now consider that I don’t have a choice in the matter of preventing the “adding of the same entity multiple times”-problem and I have to deal with it after they have been added.

How can I delete duplicate entities from the ObjectStateManager, so that I can call apply changes?

  • 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-16T20:14:03+00:00Added an answer on June 16, 2026 at 8:14 pm

    How can I delete duplicate entities from the ObjectStateManager, so
    that I can call apply changes?

    Only manually by searching the ObjectStateManager and resolving duplicates. That is the reason why you should resolve that issue prior to adding entities to ObjectContext or in ObjectStateManager.ObjectStateManagerChanged event handler.

    Anyway you are asking wrong question. Even if you delete duplicate entities from ObjectStateManager it will not solve the problem. Deleting entities will just break your object graphs. You also need to fix all references to deleted entities and point them to single remaining entity instance.

    This issue is usually handled directly by serialization / deserialization and if you write it yourselves you should do it as well.

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

Sidebar

Related Questions

Because calling a flush() to get every entities persist from memory to database. So
Calling this powershell command and getting an error. Driving me nuts. Prompt> get-childitem -recurse
Calling Index view is giving me this very very annoying error . Can anybody
Calling all AutoMapper gurus! I'd like to be able to map object A to
Calling index.php?pConta=1&pDataInicial=01-01-2000&pDataFinal=31-12-2000 I get this notices: [08-Oct-2009 17:30:35] PHP Notice: Undefined index: pConta in
Calling the function on load and the error is pointing to that. I don't
Calling Array.indexOf(input Array,A) gives the index of A in input Array.But how to get
Calling system() to run an external .exe and checking error code upon errors: #include
Calling Virtual methods during construction and destruction causes a compiler error? I heard that
Calling expert Scala developers! Let's say you have a large object representing a writable

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.