I want to develop my own custom scaffolding in VS2017 Community for Controllers and Views in an MVC5 project (not using .NET Core), but I am having a little trouble with it.
I've copied the templates from this location into my project under CodeTemplates:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\Extensions\Microsoft\Web\Mvc\Scaffolding
However, I don't want to modify the existing templates, but create my own new ones.
If I try to add a t4 template under CodeTemplates like MyController\Controller.cs.t4 or AddController\MyController\Controller.cs.t4, it will not show up as an option in the menus if I try to right-click on my Controllers folder and add a new Controller or New Scaffolded Item.
Firstly, if I build something like Controller.cs.t4, how do I create a new file from it as say HelloWorldController.cs? Can't seem to find where to look. These are good articles, but I'm having trouble finding what to do about having a t4 template generate a different filename like VS does.
https://msdn.microsoft.com/en-us/library/dd820620.aspx
https://msdn.microsoft.com/en-us/library/bb126478.aspx
What I would like to basically do, is right click on a Model, click a context menu button in VS, and have it call some code I would write that looks at the public functions of the Model via Reflection and procedurally generates the Controller and Views from it using my own templates and places them in the appropriate subfolders.
I may also want it to involve a dialog with other controls, much like the existing Scaffolding menu options work when using an EF Context. Looking at the existing templates that involve EF Context they call this line:
<#@ ScaffoldingAssembly Processor="ScaffoldingAssemblyLoader" #>
I'm not sure where that sits and how to create my own and reference it is the question.
I may also want an entirely separate template implementation of what exists under CodeTemplates\MvcView that may become a partial view of an SPA page, allowing me to call the CRUD methods via AJAX instead of having it on its own page.
This is already getting a little bit out of hand, and I'm unsure whether this is actually one question or multiple. I'm asking for basically one essential function, but it seems to be composed of several questions: how to process a T4 C# template at design time into a new filename, how to do so with some code that VS understands (does this require VISX knowledge?) and generate the necessary dialogs to set the parameters and run the necessary T4 templates to create files, and how to add that to the standard MVC project right-click context menu (is VISX the solution for this?). I keep asking about VISX because when I look "Custom Command" in a VISX project it's saying it wants to add it to the Tools menu, I don't want it there but on Project's context menu the same way as Controllers, is that only a matter of running Tools -> Customize?
I'm just getting started looking into VISX right now, very excited about it, but there's lots to cover of course.