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

[5.0.1] Only accept non-default store-generated values #23186

Merged
merged 2 commits into from
Nov 12, 2020

Conversation

AndriySvyryd
Copy link
Member

@AndriySvyryd AndriySvyryd commented Nov 4, 2020

Fixes #23180

Description

When propagating store-generated value from the principal entry to the dependent we set the FK store-generated value to null if there was any, due to #22603. When accepting the values on the dependent entry we overwrite the propagated value with the "store-generated" null.

EF expects that the properties that currently have the default value to be store-generated. Therefore it is reasonable to only accept the store-generated value if it's different from the default.

Customer Impact

Inserting a non-TPT dependent and two principals or a TPT-dependent and a principal when the principals have store-generated primary keys will result in a navigation to principal being set to null.

It is possible to manually set the navigation after calling SaveChanges as a workaround, but this situation is hard to detect and could lead to data corruption.

How found

Reported by user on RC2

Test coverage

This PR includes tests for the affected scenario.

Regression?

No, this issue existed in 3.1, but was made more likely to surface by the introduction of TPT

Risk

Medium. The modified code is used in all SaveChanges scenarios with store-generated values.

@ajcvickers
Copy link
Member

Approved by Tactics for 5.0.1.

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