[Foreign Key] created but there is no relation in the Database

Issue #45 closed
john_dev created an issue

I have 2 tables with OneToMany relationship:

    [Table("Account")]
    public class Account
    {
        [PrimaryKey, AutoIncrement, NotNull]
        public int Id { get; set; }

        [OneToMany(CascadeOperations = CascadeOperation.CascadeDelete)]
        public List<Check> Checks { get; set; }
    }

    [Table("Check")]
    public class Check
    {
        [PrimaryKey, AutoIncrement, NotNull]
        public int Id { get; set; }

        [ForeignKey(typeof(Account))]
        public int AccountId { get; set; }
    }

After creation, there is a "Check_AccountId" index in the database but as you see there is no relation between the tables:

tables.png

On the other hand, I can't make the Foreign Key works (created) without an error.

What happens?

Comments (6)

  1. Guillermo Gutiérrez

    Hi John,

    As stated in the project description, SQLite-Net Extensions doesn't perform any change in your database schema. So there's no explicit relation created in the database.

    On the other hand, can you explain in detail the error that you are getting?

  2. john_dev reporter

    Thanks for the reply,

    There is no error. But if there is no change in the schema and no foreign key created, so how it works?

    How can I rely the database?

  3. john_dev reporter

    Thank you for your information.

    So as far as I understand, all things handled in the code at runtime and there is no exact relation in the database.

  4. Log in to comment