开发者

Fluent nHibernate - unfriendly many-to-one reference name

开发者 https://www.devze.com 2022-12-15 13:47 出处:网络
I define my data model using Fluent nHibernate POCO classes + mappings. I\'m also using nHiberate schema to create database schema.

I define my data model using Fluent nHibernate POCO classes + mappings. I'm also using nHiberate schema to create database schema. All is working fine but there is one unpleasent fact. When I use many-to-one reference referece is named by something similair to GUID ins开发者_运维百科tead of any descriptive name. Here's a piece of SQL:

alter table [Odbiorca] 
        add constraint FK291D244B5D9E8115 
        foreign key (Adr_IdKraj) 
        references [Kraj]

I want nHiberate to generate something like Sql Studio does like [FK_Odbiorca_Kraj]. Is it doable by overridding mappings or by creating any convention?


I don't know Fluent, but with regular XML mapping you just can use the foreign-key attribute:

<many-to-one 
  name="Kraj" 
  class="Kraj" 
  column="Adr_IdKraj" 
  foreign-key="FK_Odbiorca_Kraj"/>
0

精彩评论

暂无评论...
验证码 换一张
取 消