Custom Entity - use taxonomy fields in views I've created custom content entity, where one of fields defined in BaseFieldDefinitions() is

$fields['game_category'] = BaseFieldDefinition::create('entity_reference')
    -&gt;setLabel(t('Game category'))
    -&gt;setDescription(t('Game category'))
    -&gt;setSetting('target_type', 'taxonomy_term')
    -&gt;setRevisionable(false)
    -&gt;setCardinality(-1);
;


Now, I'm trying to create a list using Views, where one of displayed fields will be "Game category" term name. What I managed to achieve is to display that term's tid.

QUESTION: How to display term's name ?

I suppose I should add a relationship, so Views is able to make a JOIN with taxonomy table

My class exposing fields to Views looks like this:

class GameViewsData extends EntityViewsData implements EntityViewsDataInterface  {

public function getViewsTableForEntityType(EntityTypeInterface $entity_type) {
    return $entity_type-&gt;getDataTable() ? : $entity_type-&gt;getBaseTable();
}

public function getViewsData() {

$data = parent::getViewsData();

$data['game'] = array();
$data['game']['table']['group'] = t('Game Entity Table');
$data['game']['table']['provider'] = 'game_entity';

$data['game']['table']['base'] = array(
    'field' =&gt; 'id',
    'title' =&gt; t('Game Entity Table'),
    'help' =&gt; t('Game Entity Table'),
    'weight' =&gt; -10,
);

$data['game']['name'] = array(
    'title' =&gt; t('name'),
    'help' =&gt; t('name'),
    'field' =&gt; array(
        'id' =&gt; 'standard',
    ),
    'sort' =&gt; array(
        'id' =&gt; 'standard',
    ),
    'filter' =&gt; array(
        'id' =&gt; 'string',
    ),
    'argument' =&gt; array(
        'id' =&gt; 'string',
    ),
);

$data['game_entity_game__game_category'] = array();
$data['game_entity_game__game_category']['table']['group'] = t('Game Entity Table');
$data['game_entity_game__game_category']['table']['provider'] = 'game_entity';

$data['game_entity_game__game_category']['table']['join'] = array(
    'game' =&gt; array(
        'left_field' =&gt; 'id',
        'field' =&gt; 'entity_id',
    ),
);

$data['game_entity_game__game_category']['game_category_target_id'] = array(
    'title' =&gt; t('game_category_target_id'),
    'help' =&gt; t('game_category_target_id'),
    'field' =&gt; array(
        'id' =&gt; 'standard',
    ),
    'sort' =&gt; array(
        'id' =&gt; 'standard',
    ),
    'filter' =&gt; array(
        'id' =&gt; 'string',
    ),
    'argument' =&gt; array(
        'id' =&gt; 'string',
    ),
);

return $data;
}


}
You didn't say that you wanted to do this programmatically, so I'll give you the answer for doing it in the UI. Since you have defined the field game_category as an entity_reference, you can add a relationship in your view to Taxonomy. See Add a relationship to a view for an example.

Then, any field in Taxonomy will be available in your view, including the name. Since this is built into the Views UI by default, you do not need any of your getViewsData() custom code.