title: ASP.NET API service working with multiple databases
body: <p>I'm building a web .net API and basically i have Controller and Service which needs SQL query (big one) and a database to take the information. I have a lot of SQL`s and 4 databases. So the service do exactly the same thing no matter the base, but how is the best way do switch between these databases? </p>
  
  <p>The SQL's have their own DB, only for them, in which apart from their names, <code>fileNames</code> and etc. it can be seen on which Database they should be used.</p>
  
  <p>I'm using Entity Framework Code First Approach and I`m looking for options how to do it.</p>
  
  <ol>
  <li><p>Since the service always do exactly the same, maybe create 4 contexts for each base, and pass the correct one to the service in the controller (probably with IF`s, which doesn't sound good to me)</p></li>
  <li><p>Or maybe create 4 controllers depending on the Database and Context and every controller passes the correct Context... doesn't seems very logical either.</p></li>
  </ol>
  
  <p>That is why I need your help :)</p>
  
  <p>So the overview:
  asp.net API, Controller and a Service doing always the same but for four different databases(receiving SQL query file, read the query from the DB and send the info to Front-end as Json).Also the queries have their own DB (for now).</p>