Skip to content

Default entity manager always used in fixtures ? #760

@Glideh

Description

@Glideh

I have multiple connections used by multiple entity managers with separate bundles (Symfony 3.4):

doctrine:
    dbal:
        default_connection: cnx1
        connections:
            cnx1:
#              ...
            cnx1:
#              ...
#           ...
    orm:
        default_entity_manager: em1
        entity_managers:
            em1:
                connection: cnx1
                mappings:
                    FirstBundle: ~
            em2:
                connection: cnx2
                mappings:
                    SecondBundle: ~
#           ...

I have fixtures in both, but Doctrine seem to use only the default entity manager for both.

$ console doctrine:fixtures:load -n

  > purging database
  > loading FirstBundle\DataFixtures\ORM\LoadEntity1Data
  > loading FirstBundle\DataFixtures\ORM\LoadEntity2Data
[...]
  > loading SecondBundle\DataFixtures\ORM\LoadEntity3Data

In MappingException.php line 37:

The class 'SecondBundle\Entity\Entity3' was not found
  in the chain configured namespaces FirstBundle\Entity

Is there a way to help Doctrine in our fixtures guessing which manager to use ?
This would avoid to have to use this for each distinct entity manager.

$ console doctrine:fixtures:load -n --em=em1 --fixtures=src/FirstBundle/DataFixtures/ORM
$ console doctrine:fixtures:load -n --em=em2 --fixtures=src/SecondBundle/DataFixtures/ORM

Maybe there is some simpler way I'm not aware of.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions