Easy Tutorial
❮ Prop Webcontrol Button Text Prop Webcontrol Calendar Weekenddaystyle ❯

ASP.NET MVC - Models


To learn ASP.NET MVC, we will build an Internet application.

Part 7: Adding the Data Model.


MVC Model

The MVC model contains all application logic (business logic, validation logic, data access logic) except pure view and controller logic.

With MVC, the model can control and manipulate application data.


Models Folder

The Models folder contains classes that represent the application models.

Visual Web Developer automatically creates an AccountModels.cs file, which contains models for application security.

AccountModels includes LogOnModel, ChangePasswordModel, and RegisterModel.


Adding a Database Model

The database model required for this tutorial can be created with a few simple steps:

Note:

We intentionally named the model "MovieDB". In the previous chapter, you saw "MovieDBs" (ending with an 's') for the database table. This may seem a bit odd, but this naming convention ensures that the model connects to the database table, and you must use it this way.


Adding a Database Controller

The database controller required for this tutorial can be created with a few simple steps:

Visual Web Developer will create the following files:


Adding Database Views

In the Movies folder, the following files will be automatically created:


Congratulations

Congratulations. You have added your first MVC data model to the application.

Now you can click the "Movies" tab.

❮ Prop Webcontrol Button Text Prop Webcontrol Calendar Weekenddaystyle ❯