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
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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.
回答2:
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.
回答3:
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