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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.