title: EF6 DbContext IOC Dependency
body: <p>I am using EF6  in Windows Service / Console Application.  I have successfully 
  implemented IOC/DI for my Business layer interfaces and implementation.
  Using Constructor Injection. Also I am using Object Database, Task Parallel Library. for better performance and I am happy with it.</p>
  
  <p>Also using <a href="https://github.com/tathamoddie/System.IO.Abstractions" rel="noreferrer">System.IO.Abstractions</a>  to make my code more testable.</p>
  
  <p>EF6 creates POCO clases for all the domain entities using  .tt files which are quite 
  handy. In order to perform Database queries I am writing every where</p>
  
  <pre><code>using(var db = new MyContext())
  {
  // code reading from/writing to database
  ...
  ...
  }
  </code></pre>
  
  <p>I know it is not right practise and makes noise in my code various places. 
  I want to make it loosely coupled. Now for my database operations - I am 
  confused how to go forward to make it more testable and loosely coupled..Can anyone point me to a good example,article which can be refereed to.</p>
  
  <p>2 major things I want to achive is to have more control over 
  Connection string configuration (for various servers deployment) and to have <code>DbContext</code> very loosely coupled within my code.</p>