ASP.Net Core Entity Framework Error: Data may have been modified or deleted since entities were loaded

Destinykid
 
on Mar 26, 2021 11:28 PM
8398 Views

Greetings Sir,

There are so much hype on Net core yet to host it is a problem. After hours of searching about hosting .net core on Plesk 

I deployed a sample app with no DB context Context and it ran successfully, but when I add DB context it will start showing the default error page. I don't know what else to do prior to this problem.

Database operation expected to affect 1 row(s) but actually affected 0 row(s). Data may have been modified or deleted since entities were loaded

Var findId = context.Customer.FindAsync(Id)
Context.Remove
Context.Save

Is running well on my local PC (Deleting the associated Customer Id.  But on the production server is a problem.

Download FREE API for Word, Excel and PDF in ASP.Net: Download
dharmendr
 
on Mar 27, 2021 06:52 AM

Hi Destinykid,

Check your object does it pass Primary Key Null. 

Your entity primary key field means Id is not set. It is zero. As you are trying to delete record so its Id key should have a value.