开发者

Fluent NHibernate issue with creating multi column unique index

开发者 https://www.devze.com 2023-01-31 18:29 出处:网络
I have the following fluent mapping set up for an entity: *Id(x => x.Id); References(x => x.UserNominee).UniqueKey(\"UQ_SurveyNominee\");开发者_开发技巧

I have the following fluent mapping set up for an entity:

        *Id(x => x.Id);
        References(x => x.UserNominee).UniqueKey("UQ_SurveyNominee");开发者_开发技巧
        References(x => x.SurveyRequest).UniqueKey("UQ_SurveyNominee");

        Map(x => x.NominationDate).Not.Nullable();*

Unfortunately the unique index is only created on one of the columns on the resulting SQL Server table and not both of them as I expected. What am I doing wrong?

Regards

mjj


OK I have managed to get this to work but I am not sure why it should make any difference. I had to change the mapping on the parent "SurveyRequest" entity. I changed the mapping from:

        HasMany(x => x.SurveyAwarenessNominees)
            .KeyColumn("SurveyRequest_Id")
            .LazyLoad()
            .Inverse()
            ;

to

HasMany(x => x.SurveyAwarenessNominees).Cascade.All().Inverse();

My unique index is now correctly created on the two foreign key columns.

0

精彩评论

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

关注公众号