MVC Instant Automatic Scaffolding of Entire Model (like Dynamic Data)?

1.5k Views Asked by At

Does MVC 3 have a way to automatically scaffold controllers and views for my entire code first model? For example for each of 70+ classes that I have assigned a DbSet in EF 4.2 code first? Or do I have to re-scaffold between 1 and 100 classes every time I change my huge data model?

I just about switched over to using Dynamic Data for this functionality but I think I'm changing my mind again. Too many errors and performance issues. How can I achieve Dynamic Data sweetness in MVC?

I had created a recursive object template before and was using attributes on the code first model to control the rendering. That's not necessarily what I'm looking for though. Just a way to quickly scaffold controllers and views for 70+ classes over and over and over again. Then with EF migrations and some voice command software I can work in a hammock maybe..

EDIT: I found this similar post here. Now I have to learn what powershell is I guess? Then buy a hammock?

1

There are 1 best solutions below

0
On BEST ANSWER

I used reflection to get a CSV style list of the types in my DbContext's DbSets. Then used MvcScaffolding from NuGet in the Package Manager console to foreach through them and scaffold controllers referencing my existing context type.

PM> $Types="WindowStyle", "WindowSize", "WindowPreset", "WindowGridColor",
"Window", "VinylSidingColor", "VinylShutterColor", "VinylFlowerBoxColor",
"TrimMaterial", "ThirdPartyService", "State", ....

and then

foreach($t in $Types) { Scaffold Controller -ControllerName $t -NoChildItems -DbContextType MyContext -Verbose }

I think I might have to watch for pluralization issues when scaffolding the views.