Question

When I'm adding a new strongly-typed view to an ASP.NET MVC project, I can select between different view content templates (Create Details, Edit, List). I have read these are templates based on the Visual Studio T4 code generation engine.

How can I author and configure my own templates and let them appear in the available templates when adding a new view?

OTHER TIPS

Create following folder structure:

{YourMVCProject}\CodeTemplates\AddView

Put your custom T4 templates (*.tt) in this folder. You will see the magic!

You might want to take a look at David Hayden's site: http://www.pnpguidance.net/Tag/T4.aspx -- He offers several screencasts on T4 and MVC that got me started. Also take a look at the T4 toolbox: (www.codeplex.com/t4toolbox). This provides additonal helpers for T4 templates.

You can add a package to your project using NuGet that will add the existing code templates to your project. From that point you could edit them or just create new ones in the same location and you should see them in the tooling.

http://nuget.org/List/Packages/Mvc3CodeTemplatesCSharp

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top