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

Postman automated interface testing practice

Table of contents Background Description Creating...

Implementation of importing and exporting vue-element-admin projects

vue-element-admin import component encapsulation ...

VMware12 installs Ubuntu19.04 desktop version (installation tutorial)

1. Experimental description In the virtual machin...

Detailed steps for installing Harbor, a private Docker repository

The installation of Harbor is pretty simple, but ...

HTML n ways to achieve alternate color code sample code

This article mainly introduces the sample code of...

Use ab tool to perform API stress test on the server

Table of contents 1 A brief introduction to syste...

25 Examples of News-Style Website Design

bmi Voyager Pitchfork Ulster Grocer Chow True/Sla...

Explanation and example usage of 4 custom instructions in Vue

Four practical vue custom instructions 1. v-drag ...

Vue implements Tab tab switching

This article example shares the specific code of ...

A brief discussion on the efficiency of MySQL subquery union and in

Recent product testing found a problem that when ...

In-depth understanding of Vue's method of generating QR codes using vue-qr

Table of contents npm download step (1) Import (2...

About Vue's 4 auxiliary functions of Vuex

Table of contents 1. Auxiliary functions 2. Examp...