防止 Nhibernate schemaexport 生成外键约束对有很多关系 [英] Prevent Nhibernate schemaexport from generating foreign key constraints on has many relationship
本文介绍了防止 Nhibernate schemaexport 生成外键约束对有很多关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个这样的映射:
HasMany(x => x.Orders).KeyColumn("CustomerID");
导致 schemaexport 生成这样的约束:
Which is causing a constraint like this to be generated by schemaexport:
alter table [CustomerOrder]
add constraint FK45B3FB85AF01218D
foreign key (CustomerID)
references [Customer]
我尝试在 References() 映射上添加 .NotFound.Ignore() 以禁用约束生成,但这不起作用.
I have tried adding .NotFound.Ignore() like on a References() mapping to disable the constraint from being generated but this does not work.
可以定义一个映射来强制 SchemaExport 不生成约束吗?
Can a mapping be defined that will force SchemaExport to not generate the constraint?
推荐答案
想通了:
HasMany(x => x.Orders).KeyColumn("CustomerID").ForeignKeyConstraintName("none");
埋在源代码中是一个检查,如果名称为none"则忽略创建
buried in the source is a check to ignore creation if the name is "none"
这篇关于防止 Nhibernate schemaexport 生成外键约束对有很多关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文