Pages

Tuesday 27 August 2013

NHibernate Exception while updating records: could not delete collection [CHILD_TABLE_NAME]

While updating records using NHibernate, if we get the following exception :

could not delete collection: [CHILD_TABLE_NAME]

it is because of many to one relationship between two tables.
To resolve this exception,
we just need to add inverse="true" in mapping file of parent table. for e.g.,


 <bag name="ChildTables" generic="true" inverse = "true">
      <key>
        <column name="ParentTableId" not-null="true" />
      </key>
      <one-to-many class="ChildTable" />
  </bag>

No comments:

Post a Comment