Concurrency violation, needs to turn it off

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
KW
Posts: 135
Joined: Tue 19 Feb 2008 19:12

Concurrency violation, needs to turn it off

Post by KW » Fri 13 Dec 2013 19:57

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

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Concurrency violation, needs to turn it off

Post by Shalex » Mon 16 Dec 2013 14:11

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.

KW
Posts: 135
Joined: Tue 19 Feb 2008 19:12

Re: Concurrency violation, needs to turn it off

Post by KW » Mon 16 Dec 2013 16:57

Seems to fix the issue. Thanks.

bbeda
Posts: 1
Joined: Tue 11 Feb 2014 14:36

Re: Concurrency violation, needs to turn it off

Post by bbeda » Wed 12 Feb 2014 10:49

Can you please give more details on why this happes and what side effects may the using of Found Rows have ?

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Concurrency violation, needs to turn it off

Post by Shalex » Tue 18 Feb 2014 11:45

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.

Post Reply