public bool UpdateValues(String impR, String actR, String proR, String impV, String magV)
{
bool IsInserted = false;
try
{
MatrixValues c = cecbContext.MatrixValues.First(i => i.actv_reference == actR); // primary key
c = cecbContext.MatrixValues.First(i => i.impt_reference == impR); // primary key
c = cecbContext.MatrixValues.First(i => i.proj_reference == proR); // primary key
c.mtrxV_importance = double.Parse(impV); // updated value
c.mtrxV_magnitude = double.Parse(magV); // updated value
cecbContext.SaveChanges(); // getting an error here!!!
IsInserted = true;
}
catch (Exception)
{
IsInserted = false;
}
return IsInserted;
}
尝试更新详细信息时出现错误
错误是
违反主键约束“PK_MatrixValues”。无法在对象“dbo.MatrixValues”中插入重复键。