[release/8.0] Don't throw when attempting to load from a newly Added entity with unknown FK values #32368
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.
Port of #32343
Fixes #32314
Description
EF8 contains a new feature allowing lazy-loading from detached entities. This brought up a case where lazy-loading would be wrong because shadow FK values are not known. We throw an exception for this case in EF8, but this regressed a valid scenario where the key values are not known because the entity instance is new.
Customer impact
Exception when accessing a lazy-loading enabled navigation backed by a shadow foreign key on an entity in the Added state.
How found
Customer reported on 8.0
Regression
Yes
Testing
Added regression test.
Risk
Low and quirked.