Closed BenLewies closed 9 years ago
This error occurred because the root entity did not already exist within the database. Perhaps the UpdateGraph
method can be refactored to AddOrUpdate
?
I've not yet had a deeper look at the code but UpdateGraph
generally supports add-or-update semantics for the root so that shouldn't throw an exception.
EDIT: After inspecting the callstack of your exception I'm quite sure that it's just an actual duplicate. Closing again.
Do you perhaps have a link to the original issue?
Sorry, I didn't mean a duplicate issue but a duplicate item added to your context ("An item with the same key has already been added.")... ;)
I just saw your open question regarding this on Stack Overflow. Have you been able to solve this?
I basically used a workaround whereby I created and saved an instance of the root object to the database before updating the entire graph. I wasn't able (given current time constraints) to determine why the add-or-update type of functionality is not working with my code.
If you can provide a reproduction I wouldn't mind debugging it and fixing GraphDiff if there's a bug..
I'll have to check whether I will be able to do this and get back to you... but thanks Andy.
I have the following classes:
Calling Code
I try to update the graph for the Employer root object e using the following code (I have truncated other code to try and isolate the problem):
This throws the following exception: