Solution to EF (Entity Framework) inserting or updating data errors

Solution to EF (Entity Framework) inserting or updating data errors

Error message: 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.

References:

https://stackoverflow.com/questions/1836173/entity-framework-store-update-insert-or-delete-statement-affected-an-unexpec

Reason: The primary key ID is not set to auto-increment , resulting in insertion failure.

Solution: Set the table's primary key ID to auto-increment.

MySQL setting method: right click on the table --> design table --> select primary key id --> check it.

SQL Server setting method: right click on the table --> design table --> select the primary key id --> double-click the value of "(is identifier)", change it to yes, and set the identifier increment and identifier seed to 1.

The above solution to the EF (Entity Framework) insert or update data error is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • Entity Framework Core generates columns and tracks column records
  • Entity Framework Core tools using the command line
  • Entity Framework Core association deletion
  • Summary of common errors reported by Entity Framework in C#
  • C# Example of using Entity Framework to operate Access database
  • Detailed explanation of how to apply Entity Framework in ASP.NET Core
  • Entity Framework Core implements soft deletion and query filters

<<:  Deeply understand how nginx achieves high performance and scalability

>>:  Understanding and using callback functions in JavaScript

Recommend

Vue3+TypeScript implements a complete example of a recursive menu component

Table of contents Preface need accomplish First R...

Sample code for nginx to achieve dynamic and static separation

1. Simple configuration of nginx's dynamic an...

Detailed explanation of writing multiple conditions of CSS: not

The :not pseudo-class selector can filter element...

Vue implements graphic verification code

This article example shares the specific code of ...

MySQL multi-instance deployment and installation guide under Linux

What is MySQL multi-instance Simply put, MySQL mu...

Essential conditional query statements for MySQL database

Table of contents 1. Basic grammar 2. Filter by c...

Example code for CSS to achieve horizontal lines on both sides of the text

This article introduces the sample code of CSS to...

Native JS to implement paging click control

This is an interview question, which requires the...

Implementation of Nginx domain name forwarding

Introduction to Nginx Nginx ("engine x"...

Eight common SQL usage examples in MySQL

Preface MySQL continued to maintain its strong gr...

A brief discussion on the magic of parseInt() in JavaScript

cause The reason for writing this blog is that I ...

Centos7 installation of FFmpeg audio/video tool simple document

ffmpeg is a very powerful audio and video process...

Summary of coalesce() usage tips in MySQL

Preface Recently, I accidentally discovered MySQL...