DbContext implement interface to leverage testability

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
otaviosoares
Posts: 7
Joined: Fri 22 Aug 2014 19:07

DbContext implement interface to leverage testability

Post by otaviosoares » Wed 21 Jan 2015 19:51

Hello

Is there a way of making my context implement an interface? It would certainly help me a lot by increasing testability, since I could, then, create FakeContext to use in my unit tests.

I tried doing so by creating another partial Context class and implementing my hard coded interface. But the generated context uses the DbSet concrete class instead of IDbSet abstraction, which makes my interface useless.

Please, let me know if I wasn't clear.

Thank you for your support.

Shalex
Site Admin
Posts: 8240
Joined: Thu 14 Aug 2008 12:44

Re: DbContext implement interface to leverage testability

Post by Shalex » Mon 26 Jan 2015 16:27

Please modify a predefined templates with an embedded T4 Editor which comes with Entity Developer to implement the needed code generation.

T4 documentation:

Post Reply