nhibernate identifier of an instance of was altered from 16 to 1
Category
protected long _id;
protected IList _sortRalSiteSortMaps;
配置文件
<class name="Category" table="Category">
<id name="Id" type="Int64" unsaved-value="null">
<column name="CategoryId" length="8" sql-type="bigint" not-null="true" unique="true" index="PK_Category"/>
<generator class="native" />
</id>
<bag name="SortRalSiteSortMaps" inverse="true" lazy="true" cascade="all-delete-orphan">
<key column="SortID"/>
<one-to-many class="RalSiteSortMap"/>
</bag>
</class>
RalSiteSortMap (关系表,)
protected long _id;
protected Category _sort;
配置文件
<id name="Id" type="Int64" unsaved-value="null">
<column name="id" length="8" sql-type="bigint" not-null="true" unique="true" index="PK_RalSiteSortMap"/>
<generator class="native" />
</id>
<many-to-one name="Sort" class="Category">
<column name="SortID" length="8" sql-type="bigint" not-null="true"/>
</many-to-one>
外键也建立好.
分类表Category,关系表RalSiteSortMap . 关系表中存放的是分类的ID
问题描述:当我向分类表插入数据时. 当关系表为空时,正常执行插入语句.当关系表不为空时,会报identifier of an instance of NHModel.Entities.RalSiteSortMap was altered from 16 to 1的错误.
百思不得其解,望指教