Fix for 10508. Create Association Entity automatically by convention.#21484
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.
Why not doing it for self-ref?
There was a problem hiding this comment.
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.
We should discuss with the team
There was a problem hiding this comment.
Any m2m navigation pair is potentially 2 different 1:N relationships.
There was a problem hiding this comment.
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
| } | ||
|
|
||
| private const string AssociationEntityTypeNameTemplate = "Join_{0}_{1}"; | ||
| private const string AssociationPropertyNameTemplate = "{0}_{1}"; |
There was a problem hiding this comment.
We should discuss both of these with the team
There was a problem hiding this comment.
What was the team decision WRT to FK property naming?
There was a problem hiding this comment.
@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.
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.