I get the following error when adding an entity
“An entity with the same identity already exists in this EntitySet”
The frustrating part is that it is an intermittent issue and it is very hard for me to reproduce.
My code:
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();
}
Any help would be appreciated as I do not know where to start….
Thanks
Have you tried the
containsmethod?You should be checking the contents of the
EntitySetbefore you modify it.(I don’t know the rest of your code but.. from what I’ve read, this might be a solution)