Category Archives: Code First

Code First Default Value – Easy way

There is a easy way to set default values in Entity Framework   Code first. all you need to do is just set your default value in your constructor. after all entity is also behave like an object. below example show how to set default value of IsActive Property

 public class MaterialCategory
 {

   public MaterialCategory()
   {
     IsActive=true;
   }
   public int Id { get; set; }
   public string Name {get;set; }
   public string Description { get; set; }
   public bool IsActive { get;set;}

 }
Advertisements