[release/6.0] Revert change to delete dependent when optional FK with cascade delete is set to null #27216
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.
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:
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.