-
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
Fix for 10508. Create Association Entity automatically by convention. #21484
Conversation
@lajones - It passed CLA check now. Probably intermittent error in the server. |
src/EFCore/Metadata/Conventions/Internal/ConventionDispatcher.ImmediateConventionScope.cs
Show resolved
Hide resolved
// do not create an automatic many-to-many association entity type | ||
// for a self-referencing skip navigation, or for one that | ||
// is already "in use" (i.e. has its Foreign Key assigned). | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not doing it for self-ref?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I have 2 collection navigations pointing to an Entity Type from that same Entity Type, my expectation would be two 1:N navigations to self rather than one N:N. I guess I thought that it was ambiguous, and in ambiguous cases we do nothing and let the user decide.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should discuss with the team
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any m2m navigation pair is potentially 2 different 1:N relationships.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree we should discuss with the team.
src/EFCore/Metadata/Conventions/RelationshipDiscoveryConvention.cs
Outdated
Show resolved
Hide resolved
src/EFCore/Metadata/Conventions/RelationshipDiscoveryConvention.cs
Outdated
Show resolved
Hide resolved
src/EFCore/Metadata/Conventions/RelationshipDiscoveryConvention.cs
Outdated
Show resolved
Hide resolved
src/EFCore/Metadata/Conventions/RelationshipDiscoveryConvention.cs
Outdated
Show resolved
Hide resolved
@@ -211,6 +212,191 @@ public InternalModelBuilder([NotNull] Model metadata) | |||
return entityTypeWithDefiningNavigation?.Builder; | |||
} | |||
|
|||
private const string AssociationEntityTypeNameTemplate = "Join_{0}_{1}"; | |||
private const string AssociationPropertyNameTemplate = "{0}_{1}"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should discuss both of these with the team
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was the team decision WRT to FK property naming?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AndriySvyryd Is there any reason we need special rules for FKs? We decided in the design meeting to just use the current rules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. That would be my preference as well.
fe3f06d
to
31d8567
Compare
src/EFCore/Metadata/Conventions/RelationshipDiscoveryConvention.cs
Outdated
Show resolved
Hide resolved
src/EFCore/Metadata/Conventions/RelationshipDiscoveryConvention.cs
Outdated
Show resolved
Hide resolved
src/EFCore/Metadata/Conventions/ManyToManyAssociationEntityTypeConvention.cs
Show resolved
Hide resolved
src/EFCore/Metadata/Conventions/ManyToManyAssociationEntityTypeConvention.cs
Outdated
Show resolved
Hide resolved
src/EFCore/Metadata/Conventions/ManyToManyAssociationEntityTypeConvention.cs
Show resolved
Hide resolved
565e044
to
eb03576
Compare
…t convention-time and through HasMany().WithMany() for fluent API.
eb03576
to
61f6cb9
Compare
Fixes #10508
Create Association Entity automatically by convention. Note: this is only the model building part - also need #19003 for the ChangeTracking part.