title: How to register multiple IDbConnectionFactory instances using Funq in ServiceStack.net
body: <p>How would you go about registering diferent IDbConnectionFactory instances in Funq and then access them directly within your services?  Do named instances somehow come into play here?  </p>
  
  <p>Is this the best approach to take when using different databases across services?</p>
  
  <p>Thanks!</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>An example ;).  I could be way off here because I'm pretty new to IoC, but say for example I have 2 separate database connections that I'd like to inject.  In ServiceStack, this is done in the Global.asax.</p>
  
  <pre><code>container.Register&lt;IDbConnectionFactory&gt;(c =&gt;
              new OrmLiteConnectionFactory(@"Connection String 1", SqlServerOrmLiteDialectProvider.Instance));                                             
  
  container.Register&lt;IDbConnectionFactory&gt;(c =&gt;
              new OrmLiteConnectionFactory(@"Connection String 2", SqlServerOrmLiteDialectProvider.Instance));                
  </code></pre>
  
  <p>Both of these seem to be injected honky dory.                             </p>
  
  <p>These are then accessed automatically on the service end via something like this:</p>
  
  <pre><code>public IDbConnectionFactory DbFactory { get; set; }
  </code></pre>
  
  <p>In this case, it seems to be giving me the first one registered.  How can I get access to a specific one on the service end?  Hopefully that makes it a little more clear.  </p>
  
  <p>Here's a full fledged example from ServiceStack.Examples that only uses 1 IDbConnectionFactory:
  <a href="https://github.com/ServiceStack/ServiceStack.Examples/tree/master/src/ServiceStack.MovieRest" rel="nofollow noreferrer">Movies Rest</a></p>