title: Entity Framework LINQ Insert
body: <p>I'm trying to use LINQ to insert an object in my database. My primary key is auto increment. Do I need to increment the id in my code or Entity Framework can do it?</p>
  
  <p>I have my dbContext:</p>
  
  <pre><code>TravelAgencyEntities db = new TravelAgencyEntities();
  </code></pre>
  
  <p>I'm trying to insert a User object:</p>
  
  <pre><code>User newUser = new User();
          newUser.FirstName = firstName.Text.ToString();
          newUser.LastName = lastName.Text.ToString();
          newUser.Email = email.Text.ToString();
          newUser.Password = password.Text.ToString();
  
          db.Users.Add(newUser);
          db.SaveChanges();
  </code></pre>
  
  <p>It returns an exception:</p>
  
  <pre><code>{"An error occurred while updating the entries. See the inner exception for details."}
  </code></pre>
  
  <p>I think that error is because I do not set the id in my object, but it should be auto increment. Does anyone know the problem?</p>
  
  <p>The INNER ERROR:</p>
  
  <pre><code>Cannot insert explicit value for identity column in table 'User' when IDENTITY_INSERT is set to OFF
  </code></pre>