Ok Guys, This is absolutely a weird one. So, i am fetching game information data from IGDB, and i am saving it in my database Whenever the user click on it to view more information about the game.
Give more Details: I have an object model call "Game", it contain property such as name, rating, popularity, cover, screenshots, videos, etc..., among other navigation properties.
And this is my Cover Model.. The reason why i am showing the cover model, is because it plays a role in the error...I think.. The cover model has a foreign key of gameId and other properties.
So by now you know that there is a one to one relationship between 'Game' and 'Cover'. Meaning one game can have one cover.
Now the problem:
When i click on "most" of the games, It work fine, the games get inserted and the covers also.
BUT BUT .. There is one game (as far as i know ) that when i click on it i get this error:
MySqlException: Cannot add or update a child row: a foreign key constraint fails (gamerater_db
.covers
, CONSTRAINT FK_Covers_Games_gameId
FOREIGN KEY (gameId
) REFERENCES games
(gameid
) ON DELETE CASCADE)
As for as i know this is the only one that gives that error.(the api database is quite big)
So you can see why this is weird... Most of the game is getting saved properly but this particular one is giving that error.. Keep in mind as for as i know this is the only one that is giving that error.
So, literally, i do not know where the error can be. When i debug log the game that is giving me that error before it get inserted, the gameId Is there, and the other properties such as name, rating, popularity, summary, user_id, first_release_date, etc... are also present.
The saving of game model is working for the others but not for this particular one.. Why??? Everything is the same.. any insight would be useful..