I’ve been putting together a few things that allow for mocking of Entity Framework. I wanted something that was really simple, so, something using T4 templates made sense, as this could then create the interfaces required. This solution is based on database first, which is what I required.

I followed the instructions from Slappy’s Blog which covered most of the solution.

The only part missing was what to do about IDENTITY fields, where I then followed the instructions in this Stack Overflow question which shows how to use an event with the fakeDBSet to create a number.

I’m using Moq, which I’m now preferring to Rhino Mocks.

Share →

Leave a Reply

Your email address will not be published. Required fields are marked *