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)] public String ProductName { get; set; } [Required] public decimal Price { get; set; } // Maximum length and minimum length of Description. [MaxLength(100), MinLength(10)] public string Product_Description { get; set; } } }
Comments
Post a Comment