title: Adding an identity field using code first Entity Framework
body: <p>Here is a model class <code>Employee</code> that I use in my MVC project.</p>
  <pre class="lang-java prettyprint-override"><code>public class Employee
  {
          [Required]
          public string Name { get; set; }
  
          [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
          public int EmployeeID { get; set; }
  
          [DataType(DataType.EmailAddress)]
          public string Email { get; set; }
  
          public int SkillID { get; set; }
  
          [Display(Name=&quot;Employee Skill&quot;)]
          public Skill EmployeeSkill { get; set; }
  
          public virtual List&lt;Skill&gt; EmployeeSkills { get; set; }
  
  }
  </code></pre>
  <p>As you can see, I have added the <code>[DatabaseGenerated(DatabaseGeneratedOption.Identity)]</code> attribute to the <code>EmployeeID</code> property. But still, when I try to insert without specifying the <code>EmployeeID</code>, as an input value, I get the following error...</p>
  <blockquote>
  <p>Cannot insert the value NULL into column 'EmployeeID', table 'MVCTheRightWayContext-20141028005000.dbo.Employees'; column does not allow nulls. INSERT fails.
  The statement has been terminated.</p>
  </blockquote>