added Test Apply_Changes_Should_Mark_Added_Territories_And_Same_Remov…#159
Open
edi0177 wants to merge 1 commit intoTrackableEntities:developfrom
Open
added Test Apply_Changes_Should_Mark_Added_Territories_And_Same_Remov…#159edi0177 wants to merge 1 commit intoTrackableEntities:developfrom
edi0177 wants to merge 1 commit intoTrackableEntities:developfrom
Conversation
…ed_Territory_As_Unchanged()
Collaborator
|
@edi0177 Sorry I hadn't looked at this .. I'll investigate and resolve. Let me know if you have any other insights. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added this test-case to describe the issue i'am facing with N-M Entities.
This is a simple example of my Use-Case.
I try to describe it in the northwind-shema.
Let's say i have a List of Employees.
And I have a List of Territories.
So I want to remove one Territory from one employee and add the same Territory to another employee.
But the Territory-Object is in both cases not the same, it can't be the same because one is in trackingState.Added and the other one in deleted.
Having this in object-graph leads to the
because the Entity is already Attached to the Context
Exception comes from SetEntityState
// Set state normally if we cannot perform interception if (interceptors == null) { context.Entry(item).State = state; <-- This fails if a other Territory with same id is already attached return; }My usecase is a little bit more complex but in short this is what i facing.
My Question is how to solve this or is this (maybe unwanted behavior ) in ApplyChanges and if we should maybe check if the entity is already attached and in State unchanged and if so to decide to not set the State again.