Concurrency violation, needs to turn it off
Posted: 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
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