When upgrading to drupal 9 you can encounter the following:
Call to undefined method Drupal::EntityManager()
Update
The following code is working on Drupal 8 but if you are upgrading drupal 8 to drupal 9 then Change your code from:
$entity = Drupal::EntityManager()->loadEntityByUuid($entity_type, $uuid);
to
$entity = Drupal::service('entity.repository')->loadEntityByUuid($entity_type, $uuid);