I have 2 entities Person and Address, Person has one Address.
EDIT: The Address already exists, Im just wanting to save the foreign key.
When I do this:
PersonDTO person = new PersonDTO();
person.Age = "Bob";
person.Address = new AddressDTO {Key = 123};
Save(person);
I get this exception:
Cannot insert the value NULL into column 'Key', table 'Address'; column does not allow nulls. INSERT fails.The statement has been terminated.
Mapping file fragment from Person
<class name="PersonDTO" table="Person" xmlns="urn:nhibernate-mapping-2.2">
<id name="Key" column="PersonKey" type="Guid">
<generator class="guid" />
</id>
<one-to-one name="Address" class="AddressDTOl" />
</class>
I don't understand why this happens, im giving Address Key a value. Is my approach flawed?