Share via


MVC Scaffolding

It is an auto-generated template in which models, views and controllers are created.It is used as an basic layout,so that you can customized it according to your project.

Scaffolding provide you the feature in which you select template and model and it will automatically create controller with all of its methods and views supported on them.

Main steps to perform scaffolding:

  1. Click on new project.

  2. Select ASP.Net Web Application.

  3. Now select empty project and Tick on MVC.

  4. Click OK to create project as solution explorer window show below

  5. Right click on solution select Manage NuGet Packages ,Now from top right search bar write Entity Framework and click to install them.

  6.  From solution project right click on App Data,now click Add than new item, select SQL Server Database and add them.

    1. Now open Database1.mdf file and generate Database table.

    2. Right Click on the table and select add new table .

    3. As user table created like this:

    4. Update the table before close them.

  7. Again right click on solution and click on Add than new item, windows menu bar come select Data than add ADO.Net Entity Data Model.

    1. Select the model contain as EF Designer from Database.

    2. Click next than select Database1.mdf.

    3. Tick mark on tables than click finish.

    4. Now model created as:

    5. Now build the solution after close them.

  8. Right Click on solution select new scaffold item,than select MVC Controller with views using entity framework

  9. Select the model class users(webscafartcle) and Data context class Database Entities(webscafartcle).

    1. Click OK.
    2. Now run it on browser.
  10. Click to create and users application will be like as:

       

    1. Fill this and click on create button now you can perform function edits delete and details.