using doctrine objects against a second database

Permalink
I am working on a small project partly as a learning exercise but more so as a pre-cursor to quoting for a very much ;larger project that will need to use the same approach. I am trying to use V7+ doctrine objects against a second database lets call it db2 which will be holding that data outside of C5 but still in a Mysql database. I have added a separate connect stanza in the database.php and have pre-created the tables in there.
I have created a test doctrine object called customers that is the model for the customers table in the db2 database. So far everything is going fine, but when I try to perform a simple query the error I get is Base table or view not found: 1146 Table 'c5.customers' doesn't exist.
The question is how do I get an entity from entity manager that is connected to the db2 database. I have tried this
public static function getCustomerRepository(){
$dbw = \Database::connection('db2');
$websterem = $dbw->getEntityManager();
$repo = $websterem->getRepository('\Concrete\Package\db2\Src\Entity\Customers');
return $repo;
}

What am I doing wrong?
is this even possible?

I even tried
......
$websterem = $dbw->getEntityManager(,'db2');
......

FaganSystems
 
FaganSystems replied on at Permalink Reply
FaganSystems
Update,
As a sanity check I created the table in the c5 database for the app and removed references to db2 at which point the code started working, so I am confident that apart from the issue with referencing db2 the code is sound.

for reference this is database.php
return [
'default-connection' => 'concrete',
'connections' => [
'concrete' => [
'driver' => 'c5_pdo_mysql',
'server' => 'localhost',
'database' => 'c5',
'username' => 'root',
'password' => 'Pa55w0rd',
'charset' => 'utf8',
],
'db2' => [
'driver' => 'c5_pdo_mysql',
'server' => 'localhost',
'database' => 'db2',
'username' => 'root',
'password' => 'Pa55w0rd',
'charset' => 'utf8',
],
],
];

(before anyone starts yes I am very aware that this is really bad security wise but this is running on my own dev servers behind some very good firewalls, and would never get deployed like this. )