I have configured the wizard settings. Below is the hbm file. When I run some code like this
Favourite favourite = favourites.Find(f => f.Id== id);
user.Favourites.Remove(favourite);
m_UserRepository.Save(ref user);
I get an error
NHibernate.Exceptions.GenericADOException: cannot delete collection rows: [Model.Entities.User.Favourites # 249] [SQL: SQL is not available] ---> System.Data.SqlClient.SqlException: cannot insert a NULL value in the "UserId" column , table "BE. Favorite"; column does not allow zeros. Error UPDATE.
Any suggestions on what this means, please help.
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="Model.Entities" schema="BE" assembly="Model" default-lazy="false">
<class name="Model.Entities.User, Model" table="Users" >
<id name="UserId" column="UserId" type="int" unsaved-value="0">
<generator class="native" />
</id>
<property name="UserName" column="UserName" type="string" />
<bag name="Favourites" cascade="all" lazy="true">
<key column="UserId"/>
<one-to-many class="Model.Entities.Favourite, Model"/>
</bag>
</class>
</hibernate-mapping>
Craig source
share