Mike
Mike

Reputation: 5499

What can be the causes of the ChangeConflictException?

My Code is simple:

using (var ctx = new MyDataContext())
{
    var image = ctx.Images.Single(i => i.ImageID == 3122);
    ctx.Images.DeleteOnSubmit(image);
    ctx.SubmitChanges();
}

I always get Row not found or changed.

I have read in other posts if I set Update Check to Never it will fix it, and it does. But I am more interested in why it is happening. Thanks!

Upvotes: 0

Views: 137

Answers (1)

stusherwin
stusherwin

Reputation: 1896

This is because the row you are updating is being updated by some other process (maybe a trigger) in between the time you read the row into memory and the time you attempt to write it back to the database.

Upvotes: 1

Related Questions