We have two tables in a database that have a 1:1 relationship set up in the following way:
- Table1 has a Primary Key which is an Identity column
- Table2 has a Primary Key which is a ForeignKey of Table1
This means that the primary key of Table1 & Table2 will always be the same value. The SelfService generated code seems to correctly set up a 1:1 relationship within the code.
The Problem
When trying to create a new Table2 entity item within the code, we set the PrimaryKey to be the same as the PrimaryKey in Table1. When saving we get an error message saying that Null can not be inserted into the ID field. Through debugging we found that despite setting the ID field value, it was missing from the insert statement.
Any help appreciated