How can I query on a custom content entity base fields? I am trying to write a entityQuery and add condition on the base fields I've defined.

The query:

$query = \Drupal::entityQuery('map_object')
    -&gt;condition('body', 'Test')-&gt;execute();


And the error:

Drupal\Core\Entity\Query\QueryException: 'body' not found in Drupal\Core\Entity\Query\Sql\Tables-&gt;ensureEntityTable() (line 316 of core/lib/Drupal/Core/Entity/Query/Sql/Tables.php).


The definition:

    $fields['body'] = BaseFieldDefinition::create('text_long')
      -&gt;setLabel(t('Body'))
      -&gt;setDescription(t(''))
      -&gt;setDisplayOptions('view', array(
        'label' =&gt; 'hidden',
        'type' =&gt; 'hidden',
        'weight' =&gt; 0,
      ))
      -&gt;setDisplayOptions('form', array(
        'type' =&gt; 'text_textfield',
        'weight' =&gt; 9,
      ))
      -&gt;setDisplayConfigurable('form', TRUE)
      -&gt;setDisplayConfigurable('view', TRUE);


The column "body" does exists in the entities base table.
I was missing data_table in the Entity annotation. By adding that and update the entity it allowed me to query as expected.

 *   base_table = "map_object",
 *   data_table = "map_object_field_data",