My problem is that if I want to create two tables with a [OneToMany]
relationship between these two.
public class Order : BusinessEntity
{
[PrimaryKey]
public Guid Id{ get; set; }
[MaxLength(20)]
public string Title{ get; set;}
[MaxLength(20)]
public string Location{ get; set; }
public DateTime OrderGenerated{ get; set; }
[OneToMany(CascadeOperations=CascadeOperation.All)]
public List<OrderPos> Positions{ get; set; }
}
[Table("OrderPos")]
public class OrderPos : BusinessEntity
{
[PrimaryKey]
public Guid Id{ get; set; }
[ForeignKey(typeof(Order)), ManyToOne]
public Guid OrderId{ get; set; }
[MaxLength(20)]
public string MaterialNr{ get; set; }
[MaxLength(10)]
public string State{ get; set; }
public int Amount{ get; set; }
}
The table OrderPos was created without the foreignkey and so I get an exception at the InsertOrUpdateAllWithChildren
method.
Should I use another derived class of SqliteConnection
?
Best Regards, Thomas