/// <summary>
    ///     Returns the default table name that would be used for this entity type.
    /// </summary>
    /// <param name="entityType">The entity type to get the table name for.</param>
    /// <param name="truncate">A value indicating whether the name should be truncated to the max identifier length.</param>
    /// <returns>The default name of the table to which the entity type would be mapped.</returns>
    public static string?GetDefaultTableName(this IReadOnlyEntityType entityType, bool truncate = true)
    {
        var ownership = entityType.FindOwnership();

        if (ownership != null &&
            ownership.IsUnique)
        {
            return(ownership.PrincipalEntityType.GetTableName());
        }

        var name = entityType.ShortName();

        if (entityType.HasSharedClrType &&
            ownership != null
#pragma warning disable EF1001 // Internal EF Core API usage.
            && entityType.Name == ownership.PrincipalEntityType.GetOwnedName(name, ownership.PrincipalToDependent !.Name))
#pragma warning restore EF1001 // Internal EF Core API usage.
        {
            var ownerTypeTable = ownership.PrincipalEntityType.GetTableName();
            name = ownerTypeTable != null
                ? $"{ownerTypeTable}_{ownership.PrincipalToDependent.Name}"
                : $"{ownership.PrincipalToDependent.Name}_{name}";
        }

        return(truncate
            ? Uniquifier.Truncate(name, entityType.Model.GetMaxIdentifierLength())
            : name);
    }
 private static string?GetDefaultContainer(IReadOnlyEntityType entityType)
 => entityType.IsOwned()
         ? null
         : entityType.Model.GetDefaultContainer()
 ?? entityType.ShortName();
 private static string?GetDefaultContainer(IReadOnlyEntityType entityType)
 => entityType.FindOwnership() != null
         ? null
         : (entityType.Model.GetDefaultContainer()
            ?? entityType.ShortName());