防止Nhibernate schemaexport生成外键约束有很多关系 [英] Prevent Nhibernate schemaexport from generating foreign key constraints on has many relationship

查看:187
本文介绍了防止Nhibernate schemaexport生成外键约束有很多关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的映射:
$ b $ pre $ HasMany(x => x.Orders).KeyColumn(CustomerID );

这是由schemaexport产生的一个约束:

  alter table [CustomerOrder] 
添加约束FK45B3FB85AF01218D
外键(CustomerID)
引用[Customer]

我曾尝试添加.NotFound.Ignore()像一个References()映射来禁用生成的约束,但是这不起作用。



可以定义一个映射来强制SchemaExport不生成约束吗?

解决方案

(b)
$ b

  HasMany(x => x.Orders).KeyColumn(CustomerID) .ForeignKeyConstraintName( 无);埋在源文件中的

如果名称为none,则忽略创建检查


I have a mapping like this:

HasMany(x => x.Orders).KeyColumn("CustomerID");

Which is causing a constraint like this to be generated by schemaexport:

alter table [CustomerOrder] 
    add constraint FK45B3FB85AF01218D 
    foreign key (CustomerID) 
    references [Customer]

I have tried adding .NotFound.Ignore() like on a References() mapping to disable the constraint from being generated but this does not work.

Can a mapping be defined that will force SchemaExport to not generate the constraint?

解决方案

Figured it out:

HasMany(x => x.Orders).KeyColumn("CustomerID").ForeignKeyConstraintName("none");

buried in the source is a check to ignore creation if the name is "none"

这篇关于防止Nhibernate schemaexport生成外键约束有很多关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆