Fluent NHibernate issue with creating multi column unique index
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.
精彩评论