I want to use IoC with Entity framework and Ninject. I figure I need the Generated Entity classes to implement an interface, ICRUD. There\'s a walkthrough that shows how t
What about making a base class (outside the EntityModel) that all entities derive from (a simple modification in the T4 template file) and implementing the interface in the base class once? It works perfect for me.
It was a while ago, but I did this using a T4 template... see this post: EntityFramework trigger like Auditing
The interface implementation is to be added to the T4 template while modifying it. It is not shown in the screenshots but it is mentioned as item 13 that the user has to implement the IValidate interface in the T4 template. Once the implementation is provide, the generated classes would have those implementations too.
User: notes that the generated classes (under the .tt file) implement the IValidate interface as expected
Presumably the generated entity classes are partial classes, correct?
If so, you can just add your own partial class files to specify the interfaces to be implemented - and to provide any actual implementation methods you need. I suspect that will be a lot simpler than changing what gets generated.