C# Store update、insert或delete语句影响了意外的行数(0)。实体框架中的DbUpdateConcurrencyException
我收到了带有标题消息的DbUpdateConcurrencyException异常。下面是我正在使用的代码。C# Store update、insert或delete语句影响了意外的行数(0)。实体框架中的DbUpdateConcurrencyException,c#,asp.net,entity-framework-6,C#,Asp.net,Entity Framework 6,我收到了带有标题消息的DbUpdateConcurrencyException异常。下面是我正在使用的代码。 private TestDBEntities tdbe = new TestDBEntities(); public int InsertData(CustomerInfo value) { Customer cst = new Customer(); int rslt = 0; cst.CustomerID =
private TestDBEntities tdbe = new TestDBEntities();
public int InsertData(CustomerInfo value)
{
Customer cst = new Customer();
int rslt = 0;
cst.CustomerID = value.CustomerID;
cst.CustomerName = value.CustomerName;
cst.Address = value.Address;
cst.City = value.City;
cst.PostalCode = value.PostalCode;
cst.Country = value.Country;
tdbe.Customers.Add(cst);
rslt = tdbe.SaveChanges();
return rslt;
}
是否在
客户
实体上定义了主键?如果SQL中没有非默认值,也可以在Visual Studio中定义它。那只是为了验证。你能告诉我们底层的SQL结构(例如创建表)吗?投票结束,因为这个问题缺少各种上下文信息。比如,InsertData
在哪里运行,这个类的生命周期是什么?类别定义是什么(客户、国家、地址等)?DbUpdateConcurrencyException
的条目中有什么内容?