An example of a solution for storing data failed due to repeated reference between multiple entities in the EDM Model

Source: Internet
Author: User
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.

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.