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

Use shared-type entity types instead of entity types with defining navigation. #23586

Merged
merged 4 commits into from
Dec 8, 2020

Conversation

AndriySvyryd
Copy link
Member

They should behave mostly the same, except that DefiningEntityType and DefiningNavigationName will return null and Name will return what FullName returned previously.

Fixes #22378

@AndriySvyryd AndriySvyryd requested a review from a team December 4, 2020 20:25
@@ -322,11 +253,6 @@ public virtual void UpdateIsKeylessConfigurationSource(ConfigurationSource confi
return newBaseType;
}

if (HasDefiningNavigation())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this enable former entity type with defining navigations to have hierarchy?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically you can specify a base type for a STET, but we don't have Fluent API for it, nor support

?? (entityType.HasSharedClrType
? entityType.FindOwnership() is ForeignKey ownership
? FindActualEntityType(ownership.PrincipalEntityType)
?.FindNavigation(ownership.PrincipalToDependent!.Name)?.TargetEntityType
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 If FK has flag for ownership then may be can annotate that PrincipalToDependent is non-null when flag is true.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know how?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[CA.MemberNotNullWhen(false, nameof(Arguments), nameof(ArgumentsPropagateNullability))]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I put [CA.MemberNotNullWhen(true, nameof(PrincipalToDependent))] on IsOwnership it doesn't help even if I use entityType.GetForeignKeys().FirstOrDefault(fk => fk.IsOwnership) instead of entityType.FindOwnership. I don't think the compiler is smart enough

…vigation.

They should behave mostly the same, except that DefiningEntityType and DefiningNavigationName will return true and Name will return what FullName returned previously

Fixes #22378
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace entity types with defining navigation with shared-type entity types
2 participants