Tuesday, 4 August 2015

What Is Scaffolding?

Scaffolding in ASP.NET MVC can generate the boilerplate code you need for create, read, update, and delete (CRUD) functionality in an application.

How it Work?


  1.  The scaffolding knows how to name controllers, how to name views, what code needs to go in each component, and where to place all these pieces in the project for the application to work.
  2.  Scaffolding runs only when you tell it to run, so you don’t have to worry about a code generator overwriting the changes you make to the output files.

A variety of scaffolding templates are available in MVC 5.The following sections highlight a few of the available templates.

1. MVC 5 Controller:-
Empty The empty controller template adds a Controller-derived class to the Controllers folder with the name you specify. This template will not create any views.

2. MVC 5 Controller with read/write Actions:-
 The read/write actions template adds a controller to your project with Index, Details, Create, Edit, and Delete actions. The actions inside are not entirely empty, but they won’t perform any useful work until you add your own code and create the views for each action.

3. Web API 2 API Controller:
 Scaffolders Several templates add a controller derived from the ApiController base class. You can use these templates to build a Web API for your application. 

4. MVC 5 Controller with Views, Using Entity Framework :-
This template is the template you’ll use to scaffold the store controller. This template not only generates your controller with the entire suite of Index, Details, Create, Edit, and Delete actions, but also generates all the required views and the code to persist and retrieve information from a database.


Happy Coding..