Why is Fluent NHibernate ignoring my unique constraint on a component?

自古美人都是妖i 提交于 2019-12-05 10:11:55
rebelliard

Are you using the latest version of Fluent NHibernate? According to James Gregory (Fluent NHibernate contributor), it should work.

// Else, try this hack:
Component(x => x.ExposureKey, m => 
{
    m.Map(x => x.AsOfDate).Not.Nullable();
    m.Map(x => x.ExposureId).Length(30).Not.Nullable();
}).SetAttribute("unique", "true");

It would also be good to check if the generated SQL actually has the Unique property set even if the hbm mapping files do not (could be a small bug).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!