Fluent NHibernate 创建多列唯一索引的问题
我为一个实体设置了以下流畅的映射:
*Id(x => x.Id);
References(x => x.UserNominee).UniqueKey("UQ_SurveyNominee");
References(x => x.SurveyRequest).UniqueKey("UQ_SurveyNominee");
Map(x => x.NominationDate).Not.Nullable();*
不幸的是,唯一索引仅在生成的 SQL Server 表的一列上创建,而不是像我预期的那样在两列上创建。我做错了什么?
问候
mjj
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我已经设法让它发挥作用,但我不确定为什么它会产生任何影响。我必须更改父“SurveyRequest”实体上的映射。我将映射从: 更改
为
HasMany(x => x.SurveyAwarenessNominees).Cascade.All().Inverse();
我的唯一索引现在已在两个外键列上正确创建。
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:
to
HasMany(x => x.SurveyAwarenessNominees).Cascade.All().Inverse();
My unique index is now correctly created on the two foreign key columns.