How can I determine whether a db entry's collection is part of a many-to-many relationship?

Solution 1:

Starting with EF Core 5.0, the Metadata property of collection entry is INavigationBase. Which could be actually either INavigation (for "regular" collection navigations) or ISkipNavigation (for skip navigations currently used for implicit many-to-many relationships).

Hence you could check for that interface, e.g.

if (collection.Metadata is ISkipNavigation info)
{
    // some additional info if needed
    var declaringEntityType = info.DeclaringEntityType; // the entity containing the navigation
    var targetEntityType = info.TargetEntityType; // "other side" entity
    var joinEntityType = info.JoinEntityType; // join entity
    var foreignKey = info.ForeignKey; // foreign key of join entity to this entity
    var inverse = info.Inverse; // the navigation property of the "other side" entity
}

etc.