Entity Framework contains T4 templates that can generate C# classes for database entities. However, these T4 templates don’t generate separated interfaces for the generated classes. This makes it difficult (if not impossible) to apply IoC and unit testing techniques.

Entity Interface Generator

This project contains customized T4 templates which can generate interfaces and attributes for the DbContext class and entity classes.

What are the benefits?

  • Enable IoC and Unit Tests by generating separated interfaces for entities. 
  • The interfaces could be generated in a separated and independent assembly to be redistributed without the need of the actual data access assembly. This cannot be done with EF 6.0 because of 2 exceptions which have been addressed in version 1.2.1.1 and 1.2.1.2.
    If you must have separated assemblies, please download versions prior to 1.2.1.1 and use EF 5.0. The breaking changes are introduced only in EF 6.0.
  • Generic unit test to smoke test the generated model by getting top 1 of every table.


Release Notes

Version 1.0.0.0

Generate interfaces for DbContext and entity classes.

Version 1.1.0.0

Generate attributes for DbContext and entity classes.

Version 1.2.0.0

Conditionally generate interfaces for entity classes and interfaces matching by regular expressions.

Version 1.2.1.0

Conditionally generate attributes for entity classes and interfaces matching by regular expressions.

Version 1.2.1.1

Critical Bug Fix: Entity Type Not Recognized By Entity Framework

Version 1.2.1.2

Critical Bug Fix: Navigation properties must implement ICollection<T> in order for Entity Framework to be able to track changes in collections

 

Upcoming Releases

Version 1.3.0.0

Conditionally generate interfaces for entity classes and interfaces based on their properties.

Version 1.3.1.0

Conditionally generate attributes for entity classes and interfaces based on their properties.

Version 1.4.0.0

Generate mocks and stubs for faking DbContext.

Version 2.0.0.0

Generate generic repository interfaces for CRUD.

Version 2.1.0.0

Generate generic repository interfaces for direct linking entities (one to many).

Version 2.2.0.0

Generate generic repository interfaces for indirect linking entities (many to many relationship).

Version 2.2.0.0

Generate unit tests for repositories.

Version 3.0.0.0

Generate Web API Controllers.

 


Additional works are published on my blog http://believeblog.azurewebsites.net/

Last edited Jun 1, 2014 at 2:36 PM by believe2014, version 49