Skip to content
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

Throw better exception for incorrect ownership configuration. #18484

Merged
merged 1 commit into from
Oct 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,12 @@ private IConventionRelationshipBuilder ConfigureInverseNavigation(
var ownership = entityType.FindOwnership();
if (ownership != null
&& ownership.PrincipalEntityType == targetEntityTypeBuilder.Metadata
&& ownership.PrincipalToDependent.GetIdentifyingMemberInfo() != inverseNavigationPropertyInfo)
&& ownership.PrincipalToDependent?.GetIdentifyingMemberInfo() != inverseNavigationPropertyInfo)
smitpatel marked this conversation as resolved.
Show resolved Hide resolved
{
Dependencies.Logger.NonOwnershipInverseNavigationWarning(
entityType, navigationMemberInfo,
targetEntityTypeBuilder.Metadata, inverseNavigationPropertyInfo,
ownership.PrincipalToDependent.GetIdentifyingMemberInfo());
ownership.PrincipalToDependent?.GetIdentifyingMemberInfo());
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private IReadOnlyList<RelationshipCandidate> FindRelationshipCandidates(IConvent
var targetOwnership = candidateTargetEntityType.FindOwnership();
if (targetOwnership != null
&& (targetOwnership.PrincipalEntityType != entityType
|| targetOwnership.PrincipalToDependent.Name != navigationPropertyInfo.GetSimpleMemberName())
|| targetOwnership.PrincipalToDependent?.Name != navigationPropertyInfo.GetSimpleMemberName())
&& (ownership == null
|| ownership.PrincipalEntityType != candidateTargetEntityType))
{
Expand Down Expand Up @@ -163,7 +163,7 @@ private IReadOnlyList<RelationshipCandidate> FindRelationshipCandidates(IConvent
&& (candidateTargetEntityType.IsOwned()
|| model.FindIsOwnedConfigurationSource(targetClrType) == null)
&& (ownership.PrincipalEntityType != candidateTargetEntityType
|| ownership.PrincipalToDependent.Name != inversePropertyInfo.GetSimpleMemberName()))
|| ownership.PrincipalToDependent?.Name != inversePropertyInfo.GetSimpleMemberName()))
|| (entityType.HasDefiningNavigation()
&& !candidateTargetEntityType.IsInDefinitionPath(entityType.ClrType)
&& (entityType.DefiningEntityType != candidateTargetEntityType
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore/Metadata/Internal/InternalEntityTypeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2788,7 +2788,7 @@ public virtual InternalEntityTypeBuilder GetTargetEntityTypeBuilder(
if (existingOwnership != null
&& entityType.Model.IsOwned(targetClrType)
&& (existingOwnership.PrincipalEntityType != entityType
|| existingOwnership.PrincipalToDependent.Name != navigationInfo.GetSimpleMemberName()))
|| existingOwnership.PrincipalToDependent?.Name != navigationInfo.GetSimpleMemberName()))
{
return configurationSource.HasValue
&& !targetClrType.Equals(Metadata.ClrType)
Expand Down
Loading