EF insert using SQL view suddenly giving optimistic concurrency error

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
DaveW
Posts: 5
Joined: Wed 17 Apr 2019 15:11

EF insert using SQL view suddenly giving optimistic concurrency error

Post by DaveW » Mon 14 Sep 2020 15:05

For the last few weeks I am seeing the following error in my development code whenever any insert using an SQL view happens in our code base -
"Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=472540 for information on understanding and handling optimistic concurrency exceptions."
App is using EF6.2
My colleagues do not get the error using the exact same code (pull my feature branch and run it). We are using VS2019 and Devart’s Entity Developer.
This all started after updates to my development machine e.g. VS 16.7.1, ED 6.8.1049, etc.
Pseudo code which is failing

Code: Select all

context.<model class>.AddObject(model);
context.SaveChanges(); <= Error happens when this executes
The class maps through Entity Developer (model first) to a SQL view. This is an insert of a new object, NOT an edit of an existing one.
I know how to handle optimistic concurrency so please don't suggest ways to do that. The problem is that suddenly working code has stopped working.
I have tried, removing the updates which applied, also used a separate PC - a fresh Windows install, with older versions VS 16.6.5 and ED 6.8.1019 (also repeated using latest versions) and I still get the same error.
Error also follows if I deploy code (VS Publish) to a Cloud service but not if a colleague deploys the same code.
Any ideas are appreciated.

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

Re: EF insert using SQL view suddenly giving optimistic concurrency error

Post by Shalex » Tue 15 Sep 2020 15:19

Please specify "Found Rows=true;" in your connection string and try again. Refer to viewtopic.php?f=2&t=28529.

DaveW
Posts: 5
Joined: Wed 17 Apr 2019 15:11

Re: EF insert using SQL view suddenly giving optimistic concurrency error

Post by DaveW » Wed 16 Sep 2020 08:07

@Shalex Thanks for the reply, however isn't that only in MySQL? Never come across that one for MS SQL and so far can't find any reference to it anywhere.

Post Reply