I want to have a Template to build my MVC project controllers.
These controllers are CRUD type. Is it possible to use custom Scaffolding?
Can I Design and Run a Template for Scaffolding myself?
After searching and searching the internet, I found and searched for Scaffolding system files, but there was no VS2019 installation folder.
How can I do this?
Related
How create and use your own ASP.NET MVC scaffolding template?
In "add Controller" wizard there is an "template" option with Microsoft templates. I would like to add new ones. A customized one. is that possible?
edit
In Visual Studio 2015 there is no template option anymore.
You can modify the T4 templates used by Visual Studio. This is a good article on how to do it:
https://www.credera.com/blog/technology-insights/microsoft-solutions/create-custom-scaffold-templates-asp-net-mvc/
You copy the default templates into your project "CodeTemplates" folder. You can then alter the templates without affecting the defaults.
I'm on archlinux using mono 4.0.4 and monodevelop 5.9.
By following the Getting started guide I noticed there are some scaffolding options missing, I see some nuget packages for scaffolding but installing them didn't do much.
SO has these two questions :
How to get the MVC 3 or 4 template in MonoDevelop?
Developing ASP.NET MVC using MonoDevelop on MAC
The latter is for Mac and both of them are outdated As I'm talking about asp.net mvc 5 here.
searching didn't reveal anything apart from the Nuget packages I added and I can't see any addins in the add-in manager for this(prefer not to use beta or alpha addins).
So what to do to get these ?
P.S:
I know I can get them with yoeman but I like to use monodevelop, if yoeman can be integrated with monodevelop So I can see options like "model with view and controller" scaffolding(that is a CRUD ready application) then I'll do it.
I am assuming you are talking about the templates that are available in an ASP.NET MVC application when you select Add View or Add Controller. If this is not the case then please update your question with more information.
The templates listed when adding a new view or controller to an ASP.NET MVC project are taken from t4 template files (.tt) in the following folders:
AddIns\AspNet\CodeTemplates\CSharp\AddController
AddIns\AspNet\CodeTemplates\CSharp\AddView\Razor
You can add extra .tt files into this folder and they will be displayed in the Add View and Add Controller dialog.
Out of the box MonoDevelop/Xamarin Studio only has a few t4 templates available so you would need to either write your own or find some from elsewhere. SharpDevelop has more T4 templates or MVC which could probably be used but may require some modification.
Just getting started with customizing the generated MVC Controller / Views.
Following Steven Sanderson's post:
http://blog.stevensanderson.com/2011/04/06/mvcscaffolding-overriding-the-t4-templates/
I used the Package Manager Console to generate 3 custom templates in my VS 2012 MVC4 project
PM>Scaffold CustomTemplate View Create
PM>Scaffold CustomTemplate View Edit
PM>Scaffold CustomTemplate View _CreateOrEdit
which creates a the files in:
CodeTemplates\Scaffolders\MvcScaffolding.RazorView
_CreateOrEdit.cs.t4 Create.cs.t4 Edit.cs.t4
But, when I "Add Controller" and choose the template
Mvc Controller with read/write actions and views using Entity Framework
The new templates are NOT being used ???
I was able to modify the create.tt edit.tt templates with notepad in
the VS 2012 folder and then generate with the changes in my project.
C:\Program Files\Microsoft Visual Studio 11.0\Common7\IDE\VWDExpress\ItemTemplates\CSharp\Web\MVC 4\CodeTemplates\AddView\CSHTML
Anyone know what I'm doing wrong ?
Thanks, LA Guy
Try creating a CodeTemplates\AddView\CSHTML folder inside your solution and put your templates there (or CodeTemplates\AddController for a controller template). It worked for me in VS2012. These can be checked into source control and everyone can share them. The ones in your VS install directory are a bit harder to share.
With the newest MVC tools, when I add a controller, I get scaffolding for the controller code as well as the CRUD Views. I'm not asking about how to override templates. I understand that I can override the T4 scaffolding templates, but I would like to see the existing built-in scaffolding templates that support the default code generation.
Where can I find the T4 code that supports the built-in/default scaffolding for MVC Views and Controllers?
Per Hansleman:
C:\Program Files (or x86)\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates\CSharp (or Visual Basic)\Web\MVC (or 2) 3\CodeTemplates
I have written two separate project templates to create MVC3 projects (both based on the standard Microsoft template, but with additional controllers/views of my own) - one with ASPX views, and the other with Razor views.
But, rather than have two separate templates, I would rather mimic the way that the Microsoft MVC3 template works, which offers both view engine options, selected in a second dialog. I know that this is done with a Wizard, but I can't find the Wizard in the MVC source code (which I've downloaded). Does anybody know where to find the Wizard, or have other helpful suggestions? Thanks.
The custom MVC New Project dialog exists in Microsoft.VisualStudio.Web.Mvc.3.0.dll. We do not ship the source code for that assembly.
I used the Export Template Wizard to create an ASP.NET MVC3 Project Template of my own. This worked OK, but did not offer the same options that Microsoft ships with their Visual Studio MVC assembly. I also ran into an issue where the strongly-typed views were not being updated with the correct namespace. They were keeping the namespace of my original project, while the Controllers and Model was correct.
We would love to have the source code made available for MVC 3 Project Templates!
Here is the Wizard I used. It definitely comes in handy. http://visualstudiogallery.msdn.microsoft.com/57320b20-34a2-42e4-b97e-e615c71aca24/
Phil Haack has documented how to create a custom MVC3 project template that will appear inside that wizard (as opposed to a normal project template that won't)
haacked.com/archive/2011/06/06/creating-a-custom-asp-net-mvc-project-template.aspx
If you follow that process you'll only end up with razor as the possible view engine. To get other view engines, you need to expand the reg files to list spark etc. Details on doing that are provided in this stack overflow answer:
Add custom viewengine to New project dialog?