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

前端 未结 8 1875
孤城傲影
孤城傲影 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 have run into this before. This error means you are trying to assign a value explicitly to a column where the database automatically assigns it.

    Suggestion: Update your edmx file to reflect any changes you may have made in the database. If the database automatically assigns the value, you should see the "IsDbGenerated=true" attribute in your designer file under that property. If it's not there, you can add it manually.

提交回复
热议问题