Creating account type where email not required to be unique
This answer is untested and it should serve as a guidance. Use it at your risk.

mymodule_entity_base_field_info_alter(&amp;$fields, EntityTypeInterface $entity_type) {
  if ($entity_type-&gt;id() == 'user' {
    unset($fields['mail']['constraints']['UserMailUnique']);
  }
}


If it doesn't work, try the following code.

$email_definition = &amp;$fields['mail']['constraints'];
unset($email_definition['UserMailUnique']);


As DataDefinition::&amp;offsetGet returns a reference, both should work.

Note that accessing the definition as an array is deprecated, but as long as https://www.drupal.org/node/2346329 is unresolved there's hardly anything else you could do.