Because there is a foreign key association between the details of the project funds and the owner's income and the bidding list, the EDM model automatically establishes the following relationship:
Spaymentdetail <---> billquantity foreign key: fk_spaymentdetail_billquantity
Projectincomedetail <---> foreign key of billquantity: fk_projectincomedetail_billquantity
At the same time, a navigation attribute associated with billquantity will be added to the spaymentdetail and projectincomedetail tables, and two navigation attributes associated with the first two tables will be added to the billquantity table.
This is okay, but the following problems may occur:
The user adds a line of grain order details and selects the corresponding tender documents. At the same time, on the grain order details editing page, the quantity, unit price, and other information of the tender documents are modified. At this time, the details are added, the status of the bidding list is modified.
When you submit the information to the database for storage, first save the details to the database. Because the status of the bidding list associated with the grain order details is changed, saving the bidding list to the database is triggered, after this step is completed
The associated grain order details are newly added, which triggers saving the grain order details to the database. At this time, the primary key repetition exception occurs.
In the final analysis, the cause of the error is that when the two entities repeatedly reference the other party, the same data is saved multiple times when submitted to the database.
Finally, after analyzing the cause, it is easy to find a solution. just delete the navigation attribute of one party. In this case, it is of little significance to navigate from billquantity object to grain order details, so you can delete the two navigation attributes of the object.