Chapter 4

Models

— By K. Scott Allen

What's In This Chapter?

  • How to model the Music Store
  • What it means to scaffold
  • How to edit an album
  • All about model binding

The word model in software development is overloaded to cover hundreds of different concepts. You have maturity models, design models, threat models, and process models. It's rare to sit through a development meeting without talking about a model of one type or another. Even when you scope the term “model” to the context of the MVC design pattern, you can still debate the merits of having a business-oriented model object versus a view-specific model object (you might remember this discussion from Chapter 3).

This chapter talks about models as the objects you use to send information to the database, perform business calculations, and even render in a view. In other words, these objects represent the domain the application focuses on, and the models are the objects you want to save, create, update, and delete.

ASP.NET MVC 3 provides a number of tools and features to build out application features using only the definition of model objects. You can sit down and think about the problem you want to solve (like how to let a customer buy music), and write plain C# classes, like Album, ShoppingCart, and User, to represent the primary objects involved. Then when you are ready, you can use tools to construct the controllers and views for the standard index, create, edit, and delete scenarios for each of the model objects. The ...

Get Professional ASP.NET MVC 3 now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.