views:

212

answers:

2

Does anyone know why NHibernate generates a field named 'elt' of type int for a many to many mapping? I'm wondering why I need it. Thanks

+4  A: 

The "elt" field is the foreign key to the element in the many-to-many mapping. In the join table, you should see two foreign key columns, id (for the parent) and elt (for the element). You can use different names if you like; these are defaults.

David Crow
+1  A: 

Thanks, yes you are right with a little more playing I found that if I don't explicitly name the column it defaults to elt.

<bag name="equipment" table="tb_room_equipment" lazy="false">
  <key column="roomID"/>
  <many-to-many class="Equipment" column="equipmentID"/>
</bag>

Like here, I have now named the column equipmentID; If I don't it will be named elt.