Nhibernate:null index column for collection Error
- by Quintin Par
I am working a subsonic to NH migration(I can’t change the schema) and while creating the mapping I came across this error
null index column for collection:
Company.Core.CompanyUser.Addresses
My mapping from the User side is
mapping.HasMany(x => x.Addresses).AsList().KeyColumn("user_id").Cascade.All().Inverse();
xml
<list cascade="all" inverse="true" name="Addresses">
<key>
<column name="user_id" />
</key>
<index />
<one-to-many class="Company.Core.CompanyAddress, Company.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</list>
On the Address side it is
mapping.CompositeId().KeyReference(x => x.User, "user_id").KeyProperty(x => x.Type);
xml
<composite-id mapped="false" unsaved-value="undefined">
<key-property name="Type" type="System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<column name="Type" />
</key-property>
<key-many-to-one name="User" class="Company.Core.CompanyUser, Company.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<column name="user_id" />
</key-many-to-one>
</composite-id>
When I try to load this collection as
user.Addresses
I get the index null exception.
How do I fix this error?