Search code examples
entity-framework-4ef-power-tools

Adding another t4 template to Reverse Engineer Code First process


I'm using Entity Framework Power Tools Reverse Engineer Code First to generate my poco classes, mapping files, and context from the database. I would also like for this process to create my base partial Validation classes for each entity. I am fine with writing the t4 template, but is there a way I can shoehorn that into the process when I run the Reverse Engineer Code First process?


Solution

  • I may be misunderstanding your question, but if not, one way to do it is to add the code to Entity.tt and have your class files include both the POCO class and your validation class. It's generated code that you shouldn't have to be referencing much if at all outside of intellisense in the calling code.

    Alternatively maybe you could add a new validation class generating .tt file to the ReverseEngineerCodeFirst folder, but I haven't tried it and it wouldn't surprise me if running ReverseEngineer Code First would not actually run it.