public function createAttachedEntity($entityClass, $values = [], $key = null)
    {
        if (is_string($values)) {
            $key = $values;
            $values = [];
        }

        $entity = $this->repositories->getRepository($entityClass)->create($values);

        $this->addAttachedEntity($entity, $key);

        return $entity;
    }