Entity Framework error: Cannot insert explicit value for identity column in table

前端 未结 8 1873
孤城傲影
孤城傲影 2020-11-27 07:09

I\'m getting this error on EF.

Cannot insert explicit value for identity column in table \'GroupMembers_New\' when IDENTITY_INSERT is set to OFF.

8条回答
  •  攒了一身酷
    2020-11-27 07:13

    I encountered the same problem and error message in my AspNetCore 2.x application. The only way I could solve it was by removing this line in the ModelBuilder.Entity method of the DbContext class:

    // remove: entity.Property(e => e.Id).ValueGeneratedNever();
    

提交回复
热议问题