Testing entity framwork code with moq4 and IDbContext This is some example code for mocking and testing your code that is based on entity framework. It's mainly for use when working with dependency injections and interfaces for your database. But can be used for other purposes as well.