I'm using fluent-nhibernate conventions to map my entityies:
public class HasManyConvention : IHasManyConvention
{
public void Apply(FluentNHibernate.Conventions.Instances.IOneToManyCollectionInstance instance)
{
instance.Key.Column(instance.EntityType.Name + "ID");
instance.Cascade.AllDeleteOrphan();
}
}
so this convention generate the following hibernate mapping :
<class xmlns="urn:nhibernate-mapping-2.2" mutable="true" name="ParentType, ParentTypeAssembly" table="ParentTable">
<id name="ParentIDID" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" unsaved-value="0">
<column name="ParentID" />
<generator class="identity" />
</id>
<bag cascade="all-delete-orphan" name="Childs" mutable="true">
<key>
<column name="ParentID" />
</key>
<one-to-many class="ChildType, ChildTypeAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</bag>
</class>
</hibernate-mapping>
how can i modify the convention to make the ParentID in the child table not null?
so it will look like this :
<key>
<column name="ParentID" not-null="true" />
</key>