Symfony2 Doctrine ORM Manager named “db2” does not exist
<p>I create YML entity, generate entity and config multiple connections</p>

<p>config.yml</p>

<pre><code># Doctrine Configuration
doctrine:
dbal:
    default_connection: db1
    connections:
        db1:
            driver:   '%database_driver%'
            host:     '%database_host%'
            port:     '%database_port%'
            dbname:   '%database_name%'
            user:     '%database_user%'
            password: '%database_password%'
            charset:  UTF8
        db2:
            driver:   '%database_driver2%'
            host:     '%database_host2%'
            port:     '%database_port2%'
            dbname:   '%database_name2%'
            user:     '%database_user2%'
            password: '%database_password2%'
            charset:  UTF8
    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        naming_strategy: doctrine.orm.naming_strategy.underscore
        auto_mapping: true
</code></pre>

<p>my orm.yml</p>

<pre><code>TestBundle\Entity\Test:
type: entity
table: Test
id:
    id:
        type: integer
        nullable: false
        options:
            unsigned: true
        id: true
fields:
    name:
        type: string
        nullable: false
        length: 255
        options:
            fixed: false
lifecycleCallbacks: {  }
</code></pre>

<p>after clean cache and generate entities, I try to run this code (in command controller)</p>

<pre><code>&lt;?php 

...

protected function execute(InputInterface $input, OutputInterface $output)
{
    $doctrine = $this-&gt;getContainer()-&gt;get('doctrine')-&gt;getManager('db2');
    //both methods cant work :( db2_entity_manager not found
    $doctrine = $this-&gt;getContainer()-&gt;get('doctrine.orm.db2_entity_manager');

    $test = $doctrine-&gt;getRepository('DionisDataBaseBundle:Test');

}
</code></pre>

<p>And I have error: </p>

<blockquote>
  <p>[InvalidArgumentException]<br>
    Doctrine ORM Manager named "db2" does not exist. </p>
</blockquote>