3

What options do we have for scaffolding controllers in ASP.NET MVC (v2 and v3 RC)? I know about the code templates folder and T4 but it only allows creating one .tt file and thus, replacing the default controller template with your own but what I would need is different types of templates for various types of controllers.

I've heard that Rails has huge support for this. I'm also aware of the MvcScaffold package in MVC 3 (via NuGet) as described and developed by Scott Hanselman which supports ControllerWithContext and ControllerWithRepository but I would like to take this further and since the source code hasn't been published (at least I'm not aware of it) there isn't much I can do to customize it.

What do you guys use or do?

mare
  • 13,033
  • 24
  • 102
  • 191
  • What use-case dictates code-generation of the controllers rather than simple object inheritance? – Kirk Woll Dec 02 '10 at 17:15
  • Well as I said I am open to suggestions and inheritance is one of them and I actually use it already. But inheritance still requires us to override base class methods so code still needs to be written (rather then generated by some scaffolding method). – mare Dec 02 '10 at 17:38

1 Answers1

3

There is the Generic Controller (Controller<T>) technique. Big fan.

Community
  • 1
  • 1
John Farrell
  • 24,673
  • 10
  • 77
  • 110