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
Asked
Active
Viewed 1,277 times
3 Answers
11
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
- 16,077
- 8
- 42
- 34
4
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.

Mark Dickinson
- 6,573
- 4
- 29
- 41

user17510
- 1,549
- 5
- 20
- 37
2
Just recently found out that the elt field is created if you have used a keyword like User or Role when using the Mapping By Code. This is just an observation, I have not tried using ` (backtick) to force quotes

Surya Pratap
- 495
- 8
- 17