I need get the MID for specific Entity Drupal 8 I am using the message module, so I have an entity of type 'message', as for the children I can get the machine name or the Uuid.

The problem I have is that by means of a 'hook_update_n' I need to update a field. The code I am using is:

function hook_update_8001() {

  //Change content in text field for 'caregiver_referral_incomplete'.
  $field_value = array(array('value' =&gt; 'Hello My formatted text', 'format' =&gt; 'basic_html'));

  entity_load('message', 2166)-&gt;getTemplate()-&gt;set('text', $field_value)-&gt;save();
}


With this structure, I need the Mid, but I only have the machine name or the Uuid, some way to find it with that data?
If you want to load by uuid, you can use this:

\Drupal::service('entity.repository')-&gt;loadEntityByUuid($entity_type_id, $uuid);