Search code examples
nhibernatefluent-nhibernate

Database "on delete cascade" mapping


Anybody know if fluent NHibernate can be used to generate keys with "on delete cascade", when using XML mappings for NHibernate it is called "on-delete='cascade'".

Reason I want this is that the other end of my mapping holds a large blob so it would be convenient if it just "disappeared"


Solution

  • It's simple:

    HasMany(x => x.YourCollection).Inverse().ForeignKeyCascadeOnDelete();