This is a tool I was looking for for a very long time. The Effort is a library that allows you to mock your database with basically no effort.
This is simply a database provider for Entity Framework which uses an in memory database (NMemory). Although it is still in beta version it is fully functional for most cases. I found it very usefull in unit and functional testing.
Ok someone could say: “What is the point of mocking the database and testing the EF functionality?” Well that is true, we do not need to test the EF functionality but what we definatelly need to test is the way we use it. Basically the configuration of our database context (either it is fluent or data annotation defined) is a place where we can make a mistake. Thanks to the database mock we can easilly and, what’s more important, quickly test if the Entity Framework is properly configured, entity identifiers are properly generated, navigation properties loaded, lazy properties works as expected, and so on.
Effort is distributed as a nuget package. All details can be found on the project’s page. Here I will only show how simply is to use Effort with EF Code Frist DbContext.
Those 2 lines causes the EF context fakeContext is ready to work with an empty in memory database.