I’ve been messing around with knockout.js a little bit lately and it seems like it has a lot of promise. However, I can’t seem to find any good Code Templates (aka t4 templates or .tt files) for it.
My GUESS is that the only changes that we would need would be on the view side, not the controller side, but I’d be up for looking at new controller templates too.
Where I am right now:
- Create a new MVC 4 project
- Using NuGet, install entity framework 5, jquery, jquery ui, and knockout
- Create a .edmx model by reverse engineering your existing database with Entity Framework
- Drag C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates\CSharp\Web\MVC 4\CodeTemplates from Explorer into the root of your project
- Delete CodeTemplates\AddController
- Highlight all of the items in CodeTemplates\AddView\CSHTML and blank out the text in “Custom Tool” in properties to keep them from
building - Start screwing around with Create.tt and Edit.tt to add in knockout code.
Goal Expected Input: Right Click > Add Controller … > MVC Controller using EF
Goal Expected Result: Controller & View created using EF with knockout code already in place.
If you use something similar to knockout that you like more, I’d love to hear about it!
Also, is it necessary to use addons like MVCScaffolding? It seems like you could just customize the existing templates and get the same results.
Thanks for your time!
I would go the MVCScaffolding route. You could create your own custom scaffolding script whenever you wished to add a controller, that is, as long as you can stomach PowerShell.