错误信息:
对数据库所做的更改已成功提交,但在更新对象上下文时出错。此 ObjectContext 可能处于不一致状态。内部异常消息: AcceptChanges 无法继续,因为该对象的键值与 ObjectStateManager 中的另一个对象冲突。请在调用 AcceptChanges 之前,确保键值是唯一的。
The changes to the database were committed successfully, but an error occurred while updating the object context. The ObjectContext might be in an inconsistent state. Inner exception message: AcceptChanges cannot continue because the object's key values conflict with another object in the ObjectStateManager. Make sure that the key values are unique before calling AcceptChanges.
请尝试在edmx文件中将对应实体ID的StoreGeneratedPattern改为Identity。
如下: