samedi 13 février 2016

Many-to-Many relationship in WPF with EF and SQLite

I'm following this tutorial in order to implement a local database (using SQLite) for my WPF application.

Everything works as it should, although I have a logical problem I don't know how to solve using this approach. I'll simplify it below.

Database-wise, I have 2 tables (A,B) which share a many-to-many relationship, and thus require a JOIN table as well (ABJoin).

In my actual code however, I'd like to use only 2 models: A and B, which each having a list of the other type. Like this:

public class A {
    // ...fields
    List<B> bList;
}

public class B {
    // ...fields
    List<A> aList;
}

How can it be implemented in EF+SQLite?

Searching online, I have found some solutions, but nothing that applies to SQLite, so I was not sure how they'd work.

Aucun commentaire:

Enregistrer un commentaire