title: Entity Framework error: Cannot insert explicit value for identity column in table
body: <p>I'm getting this error on EF.</p>
  
  <blockquote>
    <p>Cannot insert explicit value for identity column in table
    'GroupMembers_New' when IDENTITY_INSERT is set to OFF.</p>
  </blockquote>
  
  <p>The column on the Db is identity increment and on the EF design file, <code>StoreGeneratedPattern</code> is <code>identity</code> as well. Seems like EF is trying to insert 0 every time I try to save.</p>
  
  <p>Some suggestions says ID is reserved on tables or drop the table and rerun the scripts.</p>
  
  <p>Any ideas?</p>
  
  <p>Here's some code:</p>
  
  <pre><code>GroupMember groupMember = new GroupMember();
              groupMember.GroupId = group.Id;
              groupMember.UserId = (new UserId(group.Owner));
              //groupMember.Id = _groupContext.GroupMembers.Count();
              group.GroupMembers.Add(groupMember);
  
              _groupContext.SaveChanges();
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/SlMV3.jpg" alt="database"></p>
  
  <p><img src="https://i.stack.imgur.com/5WOf7.jpg" alt="EF Designer"></p>