ef添加数据时出错 System.Data.Entity.Infrastructure.DbUpdateConcurrencyException”类型的异常

找半天才找到 ef添加数据时出错原因:数据库表中没有主键 ,就算表中有自增列 Added方法也会报错;

-        this._db.SaveChanges()  

 “this._db.SaveChanges()”引发了“System.Data.Entity.Infrastructure.DbUpdateConcurrencyException”类型的异常    int {System.Data.Entity.Infrastructure.DbUpdateConcurrencyException}

解决办法:添加一个主键列或者给某列加主键:可以是NEWID()随机函数 给默认值,不影响数据库结构,

正在创建模型,此时不可使用上下文“的解决办法
原文地址:https://www.cnblogs.com/ln-qiqi/p/6203193.html