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.
Also using System.IO.Abstractions to make my code more testable.
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
using(var db = new MyContext())
{
// code reading from/writing to database
...
...
}
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.
2 major things I want to achive is to have more control over
Connection string configuration (for various servers deployment) and to have DbContext
very loosely coupled within my code.