Best way to handle many to many relationships?

I have need to make use of many to many relationships with my data model but am aware that ormlite does not support POCOs with multiple primary key columns. Is there a suggested best practice on how to handle this issue?

There’s no special handling for them, i.e. you’d treat it like just like any other table, e.g:

public class AB
{
    [AutoIncrement] public int Id { get; set; }
    [References(typeof(A))] public int AId { get; set; }
    [References(typeof(B))] public int BId { get; set; }
}

If preferred you can also add a Unique Constrant to enforce uniqueness.

1 Like