[release/3.1] Cherry-picking commits for for closely related detach/delete issues #19911
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.
Issues: #19203 #19137 #18982 #16546
Description
We made tweaks to the cascade delete behavior in 3.0 and also changed the default timing for when cascades happen. This change introduced several bugs which all result in deletion or severing of relationships instead of detaching them. This was then hit by more people due to the timing change.
Customer Impact
EF may incorrectly delete entities.
How found
Reported by multiple customers.
Test coverage
We were lacking good coverage for these detach scenarios. More coverage is included in this PR.
Regression?
Yes, from 2.x.
Risk
Low. Only impacts cases of detaching with cascades.
Also, fix is on by default, but quirk switch is present to revert back to old behavior.