[release/3.1] RevEng: Don't create navigations to keyless entity types #19919
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 #18633
Description
In 3.0, we started reverse engineering entity types for tables without a primary key. If the keyless table contained a foreign key, a bi-directional relationship was created for it; however navigation properties to a keyless entity type aren't allowed at runtime.
Customer Impact
The code generated by
dotnet ef dbcontext scaffold
throws at runtime and needs to be updated manually before it will work.How found
Reported by multiple customers.
Test coverage
Automated tests were added covering the various scenarios reported.
Regression?
No.
Risk
Low. Navigation properties to the keyless entity type are no longer created. An AppContext switch was added to enable reverting to the previous behavior.