46
Views
2
Comments
Solved
 error creating foreign keys
Question

Hi Guys!

I cannot send the OML, because it is a company project



two applications were created by my team, where one is dependent on the other. A Locations entity was created in application A then in application B they used the dependency for a LocationHistoric entity, where the LocationHistoric entity has a foreign key of the Location entity. However, I deleted the Location entity and created it again in the same format, but the LocationHistorical entity lost the reference, when trying to create a new reference it does not allow me to add the foreign key, generating the following error: 


Upgrade Error


Could not create foreign key constraint. This may have happened because there are 'LocalizacaoId' values of entity 'HistoricoContentor' with no corresponding value in entity 'Localizacao', or attribute 'LocalizacaoId' of entity 'HistoricoContentor' is creating a circular dependency between entities. Check the Error Log for more information.

2018-10-29 08-31-03
João Marques
 
MVP
Solution

Hi Fabiano,


The foreign key ensures that the value in that column is the id of another entity (in your case, the id of the Localizacao entity).

You cannot create a foreign key on an attribute which is already violating this premise (in your case, the attribute of HistoricoContentor has values which are not ids of the Localizacao entity).


Being that said, you can 1) delete all values from HistoricoContentor entity and then 2) add the foreign key and publish the module.


Kind Regards,
João

UserImage.jpg
Fabiano Silva

by cleaning the LocalityHistorical entity, it was possible to assign the foreign key.

Thank you friend.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.