+ // String IDs can be set when creating the entity.
+ if (!($entity->isNew() && $field_definition->getType() === 'string')) {
+ return $return_as_object ? AccessResult::forbidden('The entity ID cannot be changed.')->addCacheableDependency($entity) : FALSE;
+ }