ADDDataModel.md - brainchildservices/curriculum GitHub Wiki

Slide 1

Adding data model classes

In Solution Explorer, right click the Models folder > Add > Class.

image

Slide 2

Name the class Movie and add the following properties:

image

Slide 3

 using System;

 namespace MvcMovie.Models
 {
     public class Movie
     {
         public int ID { get; set; }
         public string Title { get; set; }
         public DateTime ReleaseDate { get; set; }
         public string Genre { get; set; }
         public decimal Price { get; set; }
     }
 }

In addition to the properties you’d expect to model a movie, the ID field is required by the DB for the primary key. Build the project. If you don’t build the app, you’ll get an error in the next section. We’ve finally added a Model to our MVC app.

Ref:- https://jakeydocs.readthedocs.io/en/latest/tutorials/first-mvc-app/adding-model.html