I have to tables, table Person and Profile. Profile has the PK of Person as FK. I also have two classes:
public class Person
{
public int Id
{
get;set;
}
public Profile Profile
{
get;set;
}
}
public class Profile
{
Public int PersonId
{
get;set;
}
Public string Language
{
get;set;
}
}
My mapping is :
public class ProfileMap : ClassMap<Profile>
{
public ProfileSettingsMap()
{
Id(x => x.PersonId).GeneratedBy.Assigned();
Map(x => x.Language, "LanguageId");
}
}
public class PersonMap : ClassMap<Person>
{
public PersonMap()
{
Id(x => x.Id).GeneratedBy.Identity();
HasOne(p => p.ProfileSettings).Cascade.All();
}
}
Now, when updating a existing Profile object, it works fine, but when trying to insert a new Profile, im getting:
could not execute batch command.[SQL: SQL not available]
The PersonId is Profile object is 0 (when debugging)
How can i fix this?
Thanks in advance