-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Relational model builder: Consistently map shadow FK properties #7240
Comments
The error is arising because, the user specified shadow FK property matched with conventional shadow FK in the other subclass, making it to share column in the database though the both FK have different uniqueness. @HappyNomad - As a work-around you can specify the FK property (different from |
can I poach this? |
Poaching this back |
Use the provider model validator in the ModelBuilding tests Fix and Refactor RelationalModelValidator.ValidateSharedTableCompatibility Fixes #7240
Use the provider model validator in the ModelBuilding tests Fix and Refactor RelationalModelValidator.ValidateSharedTableCompatibility Fixes #7240
Use the provider model validator in the ModelBuilding tests Fix and Refactor RelationalModelValidator.ValidateSharedTableCompatibility Fixes #7240
Use the provider model validator in the ModelBuilding tests Fix and Refactor RelationalModelValidator.ValidateSharedTableCompatibility Fixes #7240
The documentation says that I'm not required to have FK properties in my model, and instead I can rely on the model builder to generate them as shadow properties. This works in most cases, but I've discovered an inconsistency, demonstrated by the below Scenario 4, regarding how those shadow properties are mapped to the database.
I kept the below pseudocode concise for readability, so first note the following:
Parent
andChild
entities each have anId
property.Scenario 1
Generates
ParentId
andParentId1
shadow FK properties onChild
. These then map to respective FKs in the database.Scenario 2
Generates a
ParentId
shadow FK property for each subclass. These then map to a single FK in the database.Scenario 3
Requires fluent API to specify correct dependant. Specifying a
ParentId
shadow FK property onChild
to correspond toA
renames the shadow property corresponding toB
toParentId1
. These then map to respective FKs in the database.Scenario 4
Requires fluent API to specify correct dependant. Specifying a
ParentId
shadow FK property onDisjointChildSubclass1
to correspond toA
throws an exception (see below). This is inconsistent and unnecessary; it's better to resolve the problem like in the other scenarios. Resolve it by mapping the twoParentId
shadow properties to separateParentId
andParentId1
FKs in the database.I just restored my EF-Core reference from the
dev
feed to1.2.0-preview1-22878
and retested all scenarios. The exception for Scenario 4 says:The text was updated successfully, but these errors were encountered: