Mocking EntityFramework context – Code First
When I first try to write test for class that use directly, I found that I can’t mock database context directly using for example Moq library. That’s because this class properties isn’t virtual. After some research I found that EF6 could be set up to enable mocking [1,2]. However that is not quite what I need. I had some specific requirements:
1. I want to trace operations into database tables
2. It must work for Code First EF6 configuration
3. It should be generic solution for each database table