Page 1 of 1

Concurrency violation, needs to turn it off

Posted: Fri 13 Dec 2013 19:57
by KW
I am running into the following error:

Store update, insert or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. Refresh objecstatemanager entries.

Basically what is happening is as follows:

I run a method that reapplies state to my database information. And sometimes this check sets values to values that already exist and I want that. But...now it won't let me save. I was using an older version of dotconnect for MySQL and never had this problem. Recently upgraded and I'm having all sorts of issues. So you can't do this for example, I need to be able to:

using(var db = new MyContext())
{
var address = db.Addresses.FirstOrDefault(x => x.Id == Id);

address.StreetAddress = StreetAddress; // if you are assigning
address.City = City; // all of the same values
address.State = State; // as they are
address.ZipCode = ZipCode; // in the database

db.SaveChanges(); // Then this will throw that exception
}


All of the columns in the entity model have concurrency:NONE

Re: Concurrency violation, needs to turn it off

Posted: Mon 16 Dec 2013 14:11
by Shalex
Please specify "Found Rows=true;" in your connection string and try again.

The Found Rows connection string parameter determines whether the provider will return the number of rows matched by the WHERE condition of the UPDATE statement instead of the rows actually changed as the number of changed rows.

Re: Concurrency violation, needs to turn it off

Posted: Mon 16 Dec 2013 16:57
by KW
Seems to fix the issue. Thanks.

Re: Concurrency violation, needs to turn it off

Posted: Wed 12 Feb 2014 10:49
by bbeda
Can you please give more details on why this happes and what side effects may the using of Found Rows have ?

Re: Concurrency violation, needs to turn it off

Posted: Tue 18 Feb 2014 11:45
by Shalex
The Found Rows connection string parameter changes the behaviour of dotConnect for MySQL in the way we described at http://forums.devart.com/viewtopic.php?t=28529#p97236 (our previous message in this thread).

If you encounter any "side effect" (incorrect or unexpected behaviour), let us know so that we could investigate the issue.