Unexpected behavior of doctrine entity manager
up vote
0
down vote
favorite
I have a helper service that links me to a database on the fly. $databaseName = 'db_x'; $em = $this->entityManagerProvider->get($databaseName); I can use this entity manager like this: $car = new Car(); $car->setName('Audi'); $em->persist($car); $em->flush(); It works good! Object was inserted to my db_x But If I run repository method on this entity manager: $em->getRepository('AppEntityCar')->findById(1); Then entity manager try run on my default database, not db_x. How it is possible? My service to switch database: namespace AppUtilsDatabase; use DoctrineORMEntityManager; use DoctrineORMEntityManagerInterface; class EntityManagerProvider { /** * @var EntityManagerInterface */ protected $entityManager; ...