title: Auto increment is not working on model
body: <p>I use entity framework core and mysql database.</p>
  
  <p>My model looks like this:</p>
  
  <pre><code>public class User
  {
      public int Id { get; set; }
      [Required]
      public string Name { get; set; }
  }
  </code></pre>
  
  <p>When I try to add a user I get <code>Field 'Id' doesn't have a default value</code></p>
  
  <pre><code>var user = new User {
      Name = "Whatever"
  };
  
  _dbContext.Users.Add(user);
  _dbContext.SaveChanges(); // Throws exception
  </code></pre>
  
  <p>And when I debug it I can see that my user's id value is <code>-2147482647</code></p>
  
  <pre><code>InnerException  {MySql.Data.MySqlClient.MySqlException: Field 'Id' doesn't have a default value
     at MySql.Data.MySqlClient.MySqlDataReader.ActivateResultSet(ResultSet resultSet)
     at MySql.Data.MySqlClient.MySqlDataReader.&lt;ReadFirstResultSetAsync&gt;d__62.MoveNext()
  </code></pre>
  
  <p>I tried using <code>[DatabaseGenerated(DatabaseGeneratedOption.Identity)]</code> and <code>[Key]</code>, but it didn't do anything.
  My generated migration looks like this:</p>
  
  <pre><code>    [DbContext(typeof(TetrominoContext))]
      [Migration("20170625090637_SixthMigration")]
      partial class SixthMigration
      {
          protected override void BuildTargetModel(ModelBuilder modelBuilder)
          {
              modelBuilder
                  .HasAnnotation("ProductVersion", "1.1.2");
  
              modelBuilder.Entity("Tetromino.Models.User", b =&gt;
                  {
                      b.Property&lt;int&gt;("Id")
                          .ValueGeneratedOnAdd();
  
                      b.Property&lt;string&gt;("Name")
                          .IsRequired();
  
                      b.HasKey("Id");
  
                      b.ToTable("Users");
                  });
          }
      }
  </code></pre>
  
  <p>My packages:</p>
  
  <pre><code>  &lt;ItemGroup&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" /&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" /&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.NodeServices" Version="1.1.1" /&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.2" /&gt;
      &lt;PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.2" /&gt;
      &lt;PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.1" /&gt;
      &lt;PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" /&gt;
      &lt;PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.2" /&gt;
      &lt;PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.2" /&gt;
      &lt;PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="1.1.2" /&gt;
    &lt;/ItemGroup&gt;
  </code></pre>
  
  <p>After looking at my database it looks like entity framework doesn't set field <code>Id</code> as auto-incremental, but I can't find a way to force it.</p>
  
  <p>I recreated my database to see if it would help, but the error still occurs, so I suspect that I have to modify migration somehow.</p>