Click here to Skip to main content
15,886,821 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Microsoft has provided a cool feature for generating controller and views using scaffolding of templates and you can do it by just right clicking on the controller's folder, say add controller and add then can specify the data context class,modal and then select template and click on Add buttton to generate the respective controllers and strongly typed views,but can we automate this process so that I don't have to manually go through the above steps for each and every modal and rather we can have some custom template for generating the controller and views for all the modals at one go?


Mayank Singh
Posted
Updated 10-Dec-12 22:35pm
v5
Comments
Keith Barrow 27-May-12 9:26am    
You could create a macro or a project template to do part of the work, but you'd still need to supply the macro/template with a database to generate from first. It is this last point that takes up most of the time.
Why do you need to automate this so heavily- it might help me understand your problem better.
mayankps 30-May-12 2:48am    
Tnx for the reply keith,I just want to reduce the repetitive work that I normally do, when I create admin web application to handle master tables in most of the place things remain same, and hence I want to just focus on tt file instead of focusing on individual pages that is write once and use it every where kind of approach, and by doing this I would be able to generate controllers and views for all the models and then my team have to just focus on further customization or logic implementation required for individual views.

Hope this answers your question

try using Dynamic Data Entities framework.

You can generate Entities and screens are generated using scaffolding.
 
Share this answer
 
Comments
mayankps 30-May-12 3:00am    
Hi Madhukar tnx for the reply,the above approach will generate the pages on the fly for each model and I don't want that, instead I want to generate controllers and view for all the models using MVC Scaffolding and then I want to work on them for further customization,but the problem is currently in database first approach we don't have the option for scaffolding all the models at one go.
Use T4 Template
T4 is a general-purpose templating engine you can use to generate C# code, Visual Basic code, XML, HTML, or text of any kind. The first step in using T4 is to create a template file, which is a mix of literal text, code, and processing directives. The T4 template processor will transform this file into a text file of the desired type by executing the code and processing directives inside.

The below link helps you to develop custom template for entityframework using T4 template
http://msdn.microsoft.com/en-us/data/gg558520.aspx[^]

Hope this helps
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900