An exception of type "System.Data.Entity.Infrastructure.DbUpdateException" occurred in EntityFramework.dll, but was not processed in the user code

I matched two tables and created scaffolding in MVC. After filling in the data on the form, when I click the "Create" button, the error below appears.

An exception of type 'System.Data.Entity.Infrastructure.DbUpdateException' occurred in EntityFramework.dll, but was not processed in the user code

Additional information: a value shared between entities or associations is generated in several places. Make sure the mapping does not split the EntityKey into multiple columns created by the repository.

+4
source share
2 answers

This problem usually occurs when you have a subtype table mapping, but its primary key is set to automatically create. this is problematic because EF will explicitly set the value based on the key of the root object.

If this is really a problem, then to solve it, set the " " parameter of your child table to false. i.e. remove from EDMX. Identity Specification StoreGeneratedPattern="identity"

+2
source

If you do not see an innerexception message that might help you (during debugging), I found a solution to the Identification Specification problem.

SQL Management Studio ( Server Explorer Visual Studio) , , che. , " ". "".

: http://www.technologycrowds.com/2015/07/system-data-entity-infrastructure-DbUpdateException.html

+2

Source: https://habr.com/ru/post/1543722/


All Articles