Why is the output from getDefinition($type) different from getStorage($type)->getEntityType()? In a Controller, when calling: $this-&gt;entityTypeManager()-&gt;getStorage($type)-&gt;getEntityType(), I do not have the exact same return value as: $this-&gt;entityTypeManager()-&gt;getDefinition($type).
They both return the same class (in my tests, it was ContentEntityType), but the only difference is in the entity_keys definition. Here is a diff of var export highlighting the diff between the two calls:
--- a/fromStorage.txt
+++ b/fromStorage.txt
@@ -19,6 +19,7 @@ Drupal\Core\Entity\ContentEntityType::__set_state(array(
     'uuid' =&gt; 'uuid',
     'langcode' =&gt; 'langcode',
     'published' =&gt; 'status',
+    'test' =&gt; 'entity_key_value',
     'revision' =&gt; '',
     'bundle' =&gt; '',
     'default_langcode' =&gt; 'default_langcode',

The test entity key was added after the module was installed (a custom entity). Only the $this-&gt;entityTypeManager()-&gt;getDefinition($type) call returns this entity key. The remaining of the entity definition is 100% the same.
At first, I thought that an entity update was needed, but the entity update manager detects no update to apply. Clearing the caches did not help either. Why the inconsistency? Am I missing an update call somewhere?
After digging into the internals of the entity type / storage management, I am fairly confident that I have found the answer: $this-&gt;entityTypeManager()-&gt;getStorage($type)-&gt;getEntityType() uses the result of EntityManager::getActiveDefinition which loads a sort of cached representation of the entity type. This was introduced by https://www.drupal.org/project/drupal/issues/2554235 which added the concept of last installed definition, which is meant to mitigate problems during update processes.
The difference between codebase and database means that the entity may need an update, like the following:
$codefieldstoragedef = $this-&gt;entityTypeManager-&gt;getDefinition($this-&gt;entityType-&gt;id());
\Drupal::entityDefinitionUpdateManager()-&gt;updateEntityType($codefieldstoragedef);

As $this-&gt;entityTypeManager-&gt;getDefinition() returns the codebase representation, this will tell Drupal to update the database representation with it. After doing this (preferably in a hook update), the entity keys will match.

This answer is also meant to fix some entity definition mismatch as shown in the status report page, especially regarding base fields to update which are used as entity keys.