Fixing Drupal 8 “Mismatched entity and/or field definitions” error.

Updating modules with entities in Drupal 8 is easy and strait forward, but there's are few things that you need to look out after an updating process was completed.
Sometimes, after the process that interact with entities, you'll see a "Entity/field definitions: Mismatched entity and/or field definitions" error on  status report page.

Mismatched entity and/or field definitions
Mismatched entity and/or field definitions errors

As we can see, in our case we have 2 failed fields.

The taxonomy_term.field_my_field field needs to be updated.
The taxonomy_term.field_my_second_field field needs to be updated.


Standard Drupal actions as dropping, rebuilding caches won't fix them. For errors related to en entity field definition the right way is to redefine the field or recreate it, not forgetting to clean leftovers. This is not an option if we have a set of created content items, like Taxonomy Terms, Nodes, etc.

To help us, there is special module Devel Entity Updates, with required tools. One of them is Drupal Drush command called - "devel-entity-updates"  this command will apply pending entity schema updates.              

devel-entity-updates   - You can use aliases (dentup, entup, entity-updates)

Drush command to run
drush entity-update

This Drush command need to be lunched in a site root directory. Good practice is to rebuild the cache after.

Time taken to fix this type of issues usually short, few minutes and your status report page section describing field definition will look like this. Meaning that we have fixed our broken fields definition successfully.

Field definition status
Field definition status