错误信息:
“System.InvalidOperationException”类型的异常在 EntityFramework.dll 中发生,但未在用户代码中进行处理
其他信息: Attaching an entity of type 'SH.Models.UserInfomation' failed because another entity of the same type already has the same primary key value. This can happen when using the 'Attach' method or setting the state of an entity to 'Unchanged' or 'Modified' if any entities in the graph have conflicting key values. This may be because some entities are new and have not yet received database-generated key values. In this case use the 'Add' method or the 'Added' entity state to track the graph and then set the state of non-new entities to 'Unchanged' or 'Modified' as appropriate.
源码
加了红色框框的代码就报错鸟 就加了个判断 和查了下个ID 思路就是先断表中有没有UID这条数据 如果没有就添加 有就修改