I’m using the T4 toolbox’s Linq to SQL model to generate code, and I’d like to add some serialization properties to the code that it generates. I’m not sure how to modify the generator to do this. Would I modify the actual .tt file that is installed with the toolbox? Or can I add something to the .tt file that gets created for me? Or do I have to do something else?
What’s the best way, if any, to do this?
Yes, you can modify the .tt file. It’s not a great experience, because Visual Studio doesn’t do any syntax highlighting; however, Clarius has a product that you can install that will add syntax highlighting to the templates.
In Scott Hanselman’s File/New/NerdDinner talk, he discusses the use of T4 templates used in the code generation for ASP.NET MVC, and demonstrates how they can be modified. The discussion about T4 templates begins at 23 minutes and 40 seconds into the talk.