Solution to error reported by EF (EntityFramework) when inserting or updating data, efentityframework

Source: Internet
Author: User

Solution to error reported by EF (EntityFramework) when inserting or updating data, efentityframework

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

Cause:Auto-increment is not set for primary key id, Leading to insertion failure.

Solution:The table's primary key id is set to auto-increment.

Mysql setting method:Right-click the table and choose design table> select primary key id> select.

 

Sqlserver setting method:Right-click the table and choose design table> select primary key id. Double-click the value of "(id)" and change it to "yes". Set "id increment" and "id seed" to "1.

The solution to the above EF (EntityFramework) data insertion or update error is to share all the content with you in the editor. I hope you can give us a reference, and hope you can provide more support for the customer's house.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.