Fix JSON collection navigations (#183)

Fixes #173
This commit is contained in:
Shay Rojansky
2023-01-14 17:16:21 +01:00
committed by GitHub
parent 8ce1fb1bb0
commit b986a8dab8

View File

@@ -88,10 +88,11 @@ public class NameRewritingConvention :
var ownedEntityType = foreignKey.DeclaringEntityType; var ownedEntityType = foreignKey.DeclaringEntityType;
// An entity type is becoming owned - this is a bit complicated. // An entity type is becoming owned - this is a bit complicated.
// Unless it's a collection navigation, or the owned entity table name was explicitly set by the user, this triggers table // This is a trigger for table splitting - unless the foreign key is non-unique (collection navigation), it's JSON ownership,
// splitting, which means we need to undo rewriting which we've done previously. // or the owned entity table name was explicitly set by the user.
// If this is table splitting, we need to undo rewriting which we've done previously.
if (foreignKey.IsOwnership if (foreignKey.IsOwnership
&& !foreignKey.GetNavigation(false)!.IsCollection && (foreignKey.IsUnique || !string.IsNullOrEmpty(ownedEntityType.GetContainerColumnName()))
&& ownedEntityType.GetTableNameConfigurationSource() != ConfigurationSource.Explicit) && ownedEntityType.GetTableNameConfigurationSource() != ConfigurationSource.Explicit)
{ {
// Reset the table name which we've set when the entity type was added. // Reset the table name which we've set when the entity type was added.