title: SimpleI Injector - Register multiple database connections
body: <p>I'm working with an existing Web Api that uses Simple Injector to register a single database connection. I need to make an endpoint to get info from a different db but I don't know how to register a new connection.</p>
  <p>These are the existing registrations for the main db:</p>
  <pre><code>_container.Register&lt;IDataBaseSqlServerDapper&gt;(
      () =&gt; new DataBaseSqlServerDapper(SqlServerDb.ConnectionString(),
      LogManager.GetLogger(&quot;&quot;)));
  
  _container.RegisterWebApiRequest&lt;IDbConnectionFactory&gt;(
      () =&gt; new OrmLiteConnectionFactory(SqlServerDb.ConnectionString(),
      new SqlServerOrmLiteDialectProvider()));
  
  _container.RegisterWebApiRequest(
      () =&gt; new PetaPoco.Database(Connection.SurveyEngine) {
          IsolationLevel = IsolationLevel.Snapshot
      });
  </code></pre>
  <p>So I read about RegisterCollection method and I tried the following:</p>
  <pre><code>_container.RegisterCollection&lt;IDataBaseSqlServerDapper&gt;(new[]
  {
     new DataBaseSqlServerDapper(SqlServerDb.ConnectionString(), LogManager.GetLogger(&quot;&quot;)),
     new DataBaseSqlServerDapper(AdmbbDb.ConnectionString(), LogManager.GetLogger(&quot;&quot;))
  });
  
  _container.RegisterCollection&lt;IDbConnectionFactory&gt;(new[]
  {
      new OrmLiteConnectionFactory(
          SqlServerDb.ConnectionString(), 
          new SqlServerOrmLiteDialectProvider()),
      new OrmLiteConnectionFactory(
          AdmbbDb.ConnectionString(), 
          new SqlServerOrmLiteDialectProvider())
  });
  
  _container.RegisterCollection&lt;PetaPoco.Database&gt;(new[]
  {
       new PetaPoco.Database(Connection.SurveyEngine) { 
          IsolationLevel = IsolationLevel.Snapshot },
       new PetaPoco.Database(Connection.Admbb) { 
          IsolationLevel = IsolationLevel.Snapshot }
  });
  </code></pre>
  <p>SqlServerDb, AdmbbDd and Connection are classes that contains the names of the connection strings.</p>
  <p>But I'm getting this error:</p>
  <blockquote>
  <p>The configuration is invalid. Creating the instance for type IDapperQueryFactory failed. The constructor of type DapperQueryFactory contains the parameter with name 'dataBaseSqlServerDapper' and type IDataBaseSqlServerDapper that is not registered. Please ensure IDataBaseSqlServerDapper is registered, or change the constructor of DapperQueryFactory. There is, however, a registration for IEnumerable&lt;IDataBaseSqlServerDapper&gt;; Did you mean to depend on IEnumerable&lt;IDataBaseSqlServerDapper&gt;?</p>
  </blockquote>
  <p>How can I solve this?</p>