Implementing a view relationship plugin
You shouldn't need to create a Views relationship plugin, although that might depend on any special cases with your relationship.

I've got two custom entities - a student and a school, which have been scaffolded using Drupal console. The Student has an entity reference field (school_id) which relates a Student to a School but the opposite relationship - Students belonging to a School - isn't generated by default. So to create the relationship that can be used in views, I built this hook method:

/**
 * Implements hook_views_data_alter().
 */
function school_student_views_data_alter(array &amp;$data) {
  $data['school']['student']['relationship'] = [
    'title' =&gt; t('Student'),
    'label' =&gt; t('Student'),
    'group' =&gt; 'School',
    'help' =&gt; t('Reference to students of a school'),
    'id' =&gt; 'standard',
    'base' =&gt; 'student',
    'base field' =&gt; 'school_id',
    'field' =&gt; 'id',
  ];
}


If you examine the $data array, you'll see all the data for all your views tables. It's a big list with lots of array elements. It'll make sense when you look at it. Set a breakpoint in your views_data_alter hook to inspect it (or use dpr/kpr/dpm).

What we're doing is creating a relationship from one table to another, as this relationship currently doesn't exist. I believe that the array element names 'school' and 'student' should refer to the table names we are dealing with. We're creating a relationship data alter and so 'relationship' is the child array element we need to create. Below that is just configuration.

title refers to the relationship title in your "Add relationship" modal window

label is the default name of the relationship when you create it

group is the name of the relationship group your new relationship belongs to

help is helper text/description for the relationship

This next bit is important!

id refers to the the name of the views relationship plugin you are needing to use. Because I'm not creating a complex relationship (basically a simple inner join), I'm using the Standard views relationship plugin (found in Drupal\views\Plugin\views\relationship\Standard).

Finally, base is the base table we're creating the relationship from.

base field is the join field in our base table and finally field is the field in the school table we're creating our join to.

So in use, views will create a join that in SQL looks like:

INNER JOIN {student} student_school ON school.id = student_school.school_id


Hopefully this makes sense and helps you or others out.