views:

82

answers:

1

For our test fixtures we use NHibernate to generate a database schema. We have a slight strange case in which an entity references a another entity but we don't wish to have a foreign key constraint (it should be possible to delete the referenced entity so a foreign key cannot be used).

Is it possible to specify that the generated schema does not have a foreign key for a particular relationship?

+1  A: 

Jay-

If you're using Fluent NHibernate, you can set this in either your implementation of IHasManyConvention or IReferenceConvention (if using conventions).

Cascade.SaveUpdate() should propagate the saves and updates, but leave the orphaned child objects when the parents are deleted.

In standard NHibernate HBM files, I believe the tag for a bag should look like:

<bag cascade="save-update" name="EntityName"> ... </bag>

UPDATE: Here's an informational post by Ayende on the topic of orphaning child objects and the differences with the cascade values.

http://bit.ly/bQDrv

David Longnecker