Regarding Error creating Foreign Key

Hello,

Actually, i m trying to develop Reactive Web App, to insert "Drop Down Widget" in my form i have created "1-Many" relationship between two entities according to the video in the course of "How to use the drop-down widget" but got stuck on the point ,like when i m publishing it is  giving me an error. I m just attaching a file which contains pic of that error please have a look and kindly let me know, how to resolve this problem.Will wait for your kind revert.

Hi,

Can you provide the screenshot of "Dog" and "Origin" in the data tab


Hi Rohit Jaswani,

Correct me if I'm wrong:

  • You had your Origin attribute in Dog already, and inserted some Dog records with values for it.
  • You changed the data type of Origin to be a mandatory foreign key to another new entity.

If this is the case, the problem is that you are trying to switch data types on columns of the database when there's data already there, and that data isn't valid from a referential integrity standpoint (the original Origin attribute doesn't currently have valid identifiers for the new table, so when the conversion is attempted errors happen and the whole data model change is aborted).

The solution could be to:

  1. First clear out the Origin attribute's value on existing Dog records (or replace its value with known Ids of records of the new entity). This will work as long as the original data type of Origin is compatible with the data type of the Id attribute of the new entity.
  2. Make your data model changes
  3. Publish

Hopefully you won't have any issues. If you still have issues, or this was not your problem, you can always delete all the Dog records ;) or cut and paste both entities (this will create new entities/tables that are similar to the original ones but don't have any data in them).

Hope this helps.