A custom route to an entity form will not pass the entity I want a custom route to the normal user form. So, I've added an entry to the routing file that directs my custom route to the canonical form of the User entities:

my_profile_form:
  path: '/user/{user}/my-profile-form'
  defaults:
    _form: '\Drupal\user\ProfileForm'
    _title: 'My profile form'
  requirements:
    _role: 'administrator'


When I try to open /user/1/my-profile-form with my browser, I see the following error message:


  Error: Call to a member function getEntityTypeId() on null in Drupal\Core\Entity\EntityForm->getBaseFormId() (line 106 of ...web/core/lib/Drupal/Core/Entity/EntityForm.php)


It seems that with my custom route the form does not know who the user is.

What magic must happen to inform the form about the user?
You can try using _entity_access

my_profile_form:
....
  requirements:
    _role: 'administrator',
    _entity_access: user.update
   user: \d+


See EntityAccessCheck