0

I have a c# MVC 4 Web app with code first models and controllers which i done manually.

Is there a quick way of scaffolding views from the controllers? or do i need to code it manually?

Matchbox2093
  • 986
  • 2
  • 12
  • 40

2 Answers2

0

In VS 2013, you can right-click on the view in this linereturn View(); of your controller and their is a add view option. I believe this is what you are looking for.

Andrew Diamond
  • 6,295
  • 1
  • 15
  • 33
  • adding a view only adds the @model IEnumerable line at the top of the code, i was hoping to save time and have the for loop through the model and its attributes already generated – Matchbox2093 Mar 01 '15 at 17:05
  • well have you seen [this](http://stackoverflow.com/questions/9208471/automatically-detect-all-models-to-scaffold?rq=1) post? this guy problem seems to be the same – Andrew Diamond Mar 01 '15 at 17:11
  • i used the guide within it there to generate the views and discarded the controllers in turn for modifying my own controllers. Thank you! – Matchbox2093 Mar 01 '15 at 17:26
0

If you have controller with action that returns data as list or other type then do the following.

1. right click on the action name
2. click on Add view
3. check mark on "Create a strongly typed view"
4. select your "Model class" from drop down
5. select list/as you need from "scaffold template" dropdown
6. click on add button

This will generate a view with all the attributes from your selected model

Sarmin Akter
  • 120
  • 7