title: How to set id key to be generated by the database in Entity Framework after model creation using Database First
body: <p>I am using Entity Framework in a Web API project. I have created my classes and models from an existing Database (MySQL), so I basically used the EF DbContextGenerator to generate my classes from my EDMX model.</p>
  
  <p>Read operations are working fine, but I am now at the point where I want to start adding functionality to add records to the database. I want the id for entities to be automatically assigned by the database.</p>
  
  <p>It seems like when you are following a code-first approach, one simply needs to specify:</p>
  
  <pre><code>[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  public int Id { get; set; }
  </code></pre>
  
  <p>In the class definition for the Id property. So I am tempted to simply add the "DatabaseGeneratedOption" to the class file that was generated. However, since I am using a database-first approach and my classes are basically auto-generated for me, I am not supposed to edit the class files as they will get overwritten again should I re-generate the classes again. Where/How do I set the Id value to be generated by the database rather than by the EF code?</p>