Foreign key must be set in a relationship in order for the relationship to load.

Issue #15 invalid
Jeremy Kolb created an issue

I have a few relationships where I list a foreign key as well as the object. If I set the object and save then on the next load the object doesn't load, but if I set the foreign key then it does.

Shouldn't relationships not require a foreign key and simply use the object with the relationship attribute while inferring the foreign key based off the relationship used?

Comments (2)

  1. Guillermo GutiƩrrez

    Hi Jeremy,

    Of course you shouldn't need to manipulate foreign keys manually. That's the main purpose of the library itself.

    In order to work properly you have to call UpdateWithChildren (or InsertWithChildren if it doesn't exist in the database already) to let SQLite-Net Extensions to update the foreign keys for you. The library doesn't override any standard SQLite.Net method so you maintain full control of your database. The drawback is that you have to call SQLite-Net Extension methods explicitly.

    Can you check that you are calling these methods? If that doesn't solve the issue, you can check at the code from the Integration Tests project for working sample code. If that doesn't help please attach code required to reproduce the issue so I can help you further.

    Thanks.

  2. Log in to comment