Orders Table
Id(x => x.ID, "ID");
...
HasMany<OrdersLineItems>(x => x.LineItems).KeyColumn("ID").Inverse().Cascade.All();
OrdersLineItems Table
Id(x => x.ID, "ID");
...
References(x => x.Orders, "OrdersID").ForeignKey("ID");
I am trying to set up a mapping where the ID from the Orders Table is referenced in OrdersID within OrdersLineItemsTable.
The problem I am running into is when I do: order.LineItems.Add(lineItem); within my code, I get a SQL error stating:
Cannot insert the value NULL into column 'OrdersID', table 'MyDatabase.dbo.OrdersLineItems'; column does not allow nulls. INSERT fails. The statement has been terminated.
I have monitored the SQL queries being executed and can see that the Orders record is first created and it bombs out when trying to create the OrdersLineItems record.
Any suggestions? Thanks in advance.