entities – How to “enable” the new configEntity on hook_update


I created a new configEntity on my project, now how I can create a hook_update to end-user execute and create this entity on their sites?

P.s.

  • If end-users uninstall and install again it works, but I want to create a hook_update to avoid end-users uninstall.

  • If final-user only update the code (without uninstall/install) will appear this error below:

DrupalComponentPluginExceptionPluginNotFoundException: The "my_entity" entity type does not exist. in DrupalCoreEntityEntityTypeManager->getDefinition() (line 150 of core/lib/Drupal/Core/Entity/EntityTypeManager.php).

So probably I need to create a hook_update_N to create this entity, that’s right?

But how I can do that?

Thank you so much for your help.