Chapter 5. Listing, Sorting, and Paging Through Tables

It’s time to fully integrate MVC, Bootstrap, and Knockout.js together in one example. This will be done by creating a new controller, views, and data binding with Knockout using the data that was prepopulated in Chapter 4. To aid in stubbing out the controllers and views, I am going to use Visual Studio’s scaffolding functionality.

Scaffolding is why I choose MVC and Entity Framework in my projects. When I use scaffolding, I find that I can rapidly create websites that provide basic CRUD (Create-Read-Update-Delete) functionality on any model.

This chapter will extend on the Code First DbContext and models created in Chapter 4.

Scaffolding the Author Model

Scaffolding involves creating a new controller. To do this, right-click the Controllers folder and select Add → Controller. This will start a wizard to create the new controller. In the first step, select MVC 5 Controller with views, using Entity Framework, and click Add to continue.

The Add Controller window will now be displayed (shown in Figure 5-1). It requires three pieces of configuration to complete the scaffolding process:

  • For the model class, select Author (BootstrapIntroduction.Models).
  • For the data context class, select BookContext (BootstrapIntroduction.DAL). When you selected the model, the controller name field was automatically populated with AuthorsController. Leaving as-is is perfect.
  • The Use a layout page option is left checked and empty because the default ...

Get ASP.NET MVC 5 with Bootstrap and Knockout.js now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.