无论如何确保当我在NHibernate中导出模式时,我可以确保某些列不能为空吗?
例如,在下面的情况中,Doc_ID
中的列ReuploadTable
不能为空:
<class name="Test.Generated.BusinessObjects.DocumentStore, DAL" table="document_store" lazy="true">
<id name="Id" column="Id">
<generator class="native" />
</id>
<bag name="ReuploadTables" lazy="true" cascade="all-delete-orphan" inverse="true" >
<key column="Doc_ID"></key>
<one-to-many class="ReuploadTable"></one-to-many>
</bag>
</class>
<class name="Test.Generated.BusinessObjects.ReuploadTable, DAL" table="reupload_table" lazy="true">
<id name="Id" column="ID">
<generator class="native" />
</id>
<property name="ReuploadTimes" column="ReuploadTimes" />
<property name="FilePath" column="FilePath" />
<many-to-one name="DocumentStore" column="Doc_ID" class="DocumentStore" />
</class>
这就是我插入的方式:
答案 0 :(得分:2)
可能你可以尝试设置
<key column="Doc_ID" not-null="true"></key>