Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.0.2] Detach join entity when removing added relationship #26892

Merged
merged 1 commit into from
Dec 15, 2021

Conversation

ajcvickers
Copy link
Member

Fixes #26779

Description

When a many-to-many relationship is created and then removed, the state of the join entity that represents this relationship is incorrectly changed to Deleted. This results in an attempt to delete a row in the database that does not exist.

Customer impact

Exception thrown when calling SaveChanges after adding and then removing a new many-to-many relationships.

This is a fairly fundamental error. What is not clear is why this was not reported before now, since the behavior existed in 5.0. It's possible people didn't realize it was a bug and having been manually detaching the join entity to make this scenario work.

How found

Customer reported on 6.0.

Regression

This is not a regression; the same behavior existing in 5.0. However, we believe that it is a fundamental behavior that should work, hence we believe we should patch in 6.0.

Testing

Added a range of new tests for this and related scenarios with different types of many-to-many relationships.

Risk

Low; the change is very simple, and is also quirked.

Fixes #26779

**Description**

When a many-to-many relationship is created and then removed, the state of the join entity that represents this relationship is incorrectly changed to `Deleted`. This results in an attempt to delete a row in the database that does not exist.

**Customer impact**

Exception thrown when calling SaveChanges after adding and then removing a new many-to-many relationships.

This is a fairly fundamental error. What is not clear is why this was not reported before now, since the behavior existed in 5.0. It's possible people didn't realize it was a bug and having been manually detaching the join entity to make this scenario work.

**How found**

Customer reported on 6.0.

**Regression**

This is not a regression; the same behavior existing in 5.0. However, we believe that it is a fundamental behavior that should work, hence we believe we should patch in 6.0.

**Testing**

Added a range of new tests for this and related scenarios with different types of many-to-many relationships.

**Risk**

Low; the change is very simple, and is also quirked.
@ajcvickers ajcvickers changed the base branch from main to release/6.0 December 3, 2021 20:25
@ajcvickers ajcvickers requested a review from a team December 3, 2021 20:26
@ajcvickers ajcvickers added this to the 6.0.x milestone Dec 3, 2021
@leecow leecow modified the milestones: 6.0.x, 6.0.2 Dec 14, 2021
@ajcvickers ajcvickers merged commit b3478b6 into release/6.0 Dec 15, 2021
@ajcvickers ajcvickers deleted the NacMacFeegle1203 branch December 15, 2021 09:24
@ajcvickers ajcvickers removed this from the 6.0.2 milestone Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Many To Many Exception when adding and removing same entity
3 participants