title: Entity Framework auto generate primary key
body: <p>I'm new to Entity Framework. I have a simple class:</p>
  
  <pre><code> public class User
  {
      [System.ComponentModel.DataAnnotations.Schema.DatabaseGenerated(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Identity)]
      public int UserId { get; set; }
      public string Email { get; set; }
      public string UserName { get; set; }
      public string Password { get; set; }
  
      //public UserList Users { get; set; }
  
      public User() { }
      public User(int userId, string email, string username)
      {
          UserId = userId;
          Email = email;
          UserName = username;
      }
  }
  </code></pre>
  
  <p>And my Initializer class:</p>
  
  <pre><code>public class UserDataInitializer : DropCreateDatabaseAlways&lt;UserDataContext&gt;
  {
      protected override void Seed(UserDataContext context)
      {
          var Users = new List&lt;User&gt; {
  
              new User() {UserId=1, Email="a1@gmail.com", UserName="a1", Password="123456"},
              new User() {UserId=2, Email="a2@gmail.com", UserName="a2", Password="123456"},
              new User() {UserId=3, Email="a3@gmail.com", UserName="a3", Password="123456"},
              new User() {UserId=4, Email="a4@gmail.com", UserName="a4", Password="123456"}}
  
  
          Users.ForEach(i =&gt; context.Users.Add(i));
          context.SaveChanges();
  
  
      }
  }
  </code></pre>
  
  <p>Suppose, i want add new User with UserId=100. It will auto change UserId to 5.</p>
  
  <p><strong>How i can disable this modification of EF?</strong> 'UserId' must be primary key and it's type is int.</p>