I learned how to use free nhibernate, and it's hard for me to figure out how to create my mappings. I have a table with a multi-column primary key, but I cannot display it correctly. I have the following smooth display -
public class MyEntityMappingOverride : IAutoMappingOverride<MyEntity>
{
public void Override(AutoMapping<MyEntity> mapping)
{
mapping.CompositeId()
.KeyProperty(x => x.Id_1, "Id_1")
.KeyProperty(x => x.Id_2, "Id_2");
mapping.References(x => x.otherEntity)
.Column("JoinColumn");
}
}
The problem I ran into is the composite identifier doesn't seem to work.
Here is a snippet from the generated mapping file -
<id name="Id" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<column name="Id" />
<generator class="identity" />
</id>
Then I get an error that the column (id) was not found in any query table.
Am I really mistaken that my mapping code will give the correct composite identifier? Am I missing something or doing something wrong?
source
share