Designing Model class with validation in ASP.NET MVC
The Generalized Example product model class. As given belowed. using System; // Using Data Annotation Library using System.ComponentModel.DataAnnotations; namespace modelDesigning.Models { public class Product { // Product ID Decalration // Key defines given Id is primary key [Key] // Required Annotation says its compulsory and required field. [Required] public int ProductID { get; set; } [Required] // Max Length Annotation gives maximum length for string. [MaxLength(50)] ...