private function addObjectManager(
        ContainerBuilder $container,
        MappingBag $mappingBag
    ): string {
        $reducedMappingBag = $mappingBag->getReducedMappingBag();
        $definition = new Definition('Doctrine\Common\Persistence\ObjectManager');
        $definition->setFactory([
            new Reference('base.object_manager_provider'),
            'getObjectManagerByEntityNamespace',
        ]);
        $class = $this->resolveParameterName($container, $reducedMappingBag->getEntityClass());
        $definition->setArguments([$class]);
        $aliasName = ltrim(($mappingBag->getContainerPrefix().'.'.$mappingBag->getContainerObjectManagerName().'.'.$mappingBag->getEntityName()), '.');
        $container->setDefinition(
            $aliasName,
            $definition
        );

        return $aliasName;
    }