且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

实体框架错误:无法为表中的标识列插入显式值

更新时间:2023-01-22 09:06:14

我以前遇到过这个问题.此错误意味着您正在尝试将值显式分配给数据库自动分配的列.

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.

建议:更新您的 edmx 文件以反映您可能在数据库中所做的任何更改.如果数据库自动分配值,您应该在设计器文件中的该属性下看到IsDbGenerated=true"属性.如果没有,您可以手动添加.

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.