I have created two custom entities using the Drupal Console.
These Entities will have a many to many relationship.
My research tells me that a basefield can be created as an entity-reference via BaseFieldDefinition::create('entity_reference') and added to each of the entities.
There is also a hint about adding unlimited cardinality: cardinality ->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED), I don't know if that is necessary.
If I add an entity_reference to both of the m-to-m entities how do they become related in such a way so I can run sql queries to get the needed data. I want to do something such as:
select wanted-data from entity-one inner join ???? on ???? inner join ???? on ???? where entity-one.referenceField = 'search-term'