wcf - Self Tracking Entities - AcceptChanges cannot continue because the object's key values conflict with another object in the ObjectStateManager -


I am stuck with this problem for more than a week. Hopefully someone can tell me in the right direction.

I start with a brief description of my schema.

Property 1 ---> 1 Address * -> 1 Area * -> 1 Field * -> 1 Country

Package 1 -> * Property

Use of Self Tracking Unit (STE) + WCF

Step:

  1. Call the data store for the list of assets.
  2. Call the data store for a list of packages.
  3. The user selects a package and assigns something
  4. Save the package.

In step 2, the call address is eagerly loading. References from

  p Assets. Include ("Address Area. Area. Country")  

This error is when trying to call

  context.Packages.ApplyChanges (package )  

AcceptChanges can not continue because the object's main value is contradictory with another object in ObjectState Manager. Make sure the key values ​​are unique before accepting calls.

Edit

After spying around, I came to know that this is an STE problem. The problem is that you can not continue the article with many examples of the same unit as underlined. This is my question.

How can I add one unit to my unit collection? The new institution can have related institutions, which already have a similar key in the collection. To wit. Add a new asset that can have only one address, area, region or country unit.

Here are my obligations:

  1. I should use the shipping archive because it affects UI.
  2. I can not pre-fetch all those entities which will be included because the data set is too large.
  3. I should be able to take snap-shots at any time to maintain history and use it to "undo" any changes at any time the unit

I am aware of the possible solutions suggested by Diego B. Vega , but these can not be used for my choice. Any other ideas?

FYI, I wrote a blog post with some additional suggestions that I had already had EF The forum posted in the forum is


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -