添加实体时出现以下错误
“此 EntitySet 中已存在具有相同身份的实体”
令人沮丧的部分是这是一个间歇性问题,我很难重现。我的代码:
private void OKButton_Click(object sender, RoutedEventArgs e)
{
this.IsHitTestVisible = false;
Form Form = _context.Forms.FirstOrDefault();
Form.Transactions.Add(new Transactions
{
Comments = textbox_taskcomments.Text,
By = UserID,
Name = Name,
IssuedOn = DateTime.Now,
StatusID = StatusID
});
this.DialogResult = DevExpress.Xpf.Core.DialogResult.OK;
this.Close();
}
任何帮助将不胜感激,因为我不知道从哪里开始......
谢谢