MVC Models


Other than the default model file , this project creates a model file by performing the folllowing tasks. Select the template:
   ASP.NET Core Web App (Model-View-Controller):

Add a new class into the folder with the properties:
Right-click on Models ⟹ Add ⟹ New Item... ⟹ C# Class


⇓   Add


C:\ASP.NET-workspace\BookStore1\Models\Book.cs
 using System.ComponentModel.DataAnnotations;
 namespace BookStore1.Models {

   public class Book {
     [ Key ]
     [ Required ]
     public int Id { get; set; }

     [ Display( Name = "Book Title" ) ]
     [ Required ]
     public string Title { get; set; }

     public string Genre { get; set; }

     [ DataType( DataType.Currency ) ]
     [ Range( 1, 100 ) ]
     public decimal Price { get; set; }

     [ Display( Name = "Publish Date" ) ]
     [ DataType( DataType.Date ) ]
     public DateTime PublishDate { get; set; }
   }
 }




      “It’s amazing how email has changed our lives.    
      You ever get a handwritten letter in the mail today?    
      ‘What the? Has someone been kidnapped?’”    
      — Jim Gaffigan