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

[release/6.0] Revert change to delete dependent when optional FK with cascade delete is set to null #27216

Merged
merged 1 commit into from
Feb 2, 2022

Conversation

ajcvickers
Copy link
Member

@ajcvickers ajcvickers commented Jan 19, 2022

Fixes #27174.

Description

In 6.0, we made a change to fix a "bug" (#25360) where setting the foreign key of an optional relationship to null did not trigger deletion of orphans when the relationship was configured for cascade delete. It turns out that people have been relying on this behavior--i.e. to our users, this was a feature, not a bug.

In addition, the people reporting this a breaking their apps have made a compelling case that orphans should not automatically be deleted for optional relationships with cascade delete enabled. We have discussed this, and have a three-step plan to address this:

  1. Revert the change that is breaking apps from updating to 6.0. (This PR.)
  2. Stop throwing for optional FKs if delete orphans timing is set to Never. (Setting the timing could have been a workaround, except that it still causes an exception to be thrown.) This is tracked by Stop throwing for optional FKs if delete orphans timing is set to Never. #27218.
  3. The change in this PR reverts the behavior when a foreign key is explicitly set to null. However, it may make sense to stop automatically deleting orphans in general for optional relationships with cascade delete configured. This is tracked by Stop automatically deleting orphans for optional relationships with cascade delete configured #27217.

Customer impact

Several customers have reported apps being broken when updating to EF Core 6.0.

How found

Multiple customer reports on 6.0.

Regression

Yes; regressed by #25360.

Testing

Test added in 6.0 changed to match reverted behavior.

Risk

Low. This reverts the behavior to that of 6.0 for optional relationships. Also quirked.

@leecow leecow modified the milestones: 6.0.x, 6.0.3 Jan 20, 2022
@ajcvickers ajcvickers merged commit 0dbe678 into release/6.0 Feb 2, 2022
@ajcvickers ajcvickers deleted the LetItBe0119 branch February 2, 2022 11:38
@ajcvickers ajcvickers removed this from the 6.0.3 milestone Feb 2, 2022
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.

3 participants