3
votes

I am wondering how do you setup in fluent nhibernate to tell that a relationship should NOT "Enforce Foreign Key Constraints"

http://gyazo.com/6a1cf3014b0650eb3ff5e05f855abf69

Do you just set the reference to Nullable?

1
And what is the point of an Fk that you don't enforce?HLGEM
nullable foreign keys are still enforced. only if the value is null is it "not" enforced.Cole W
The point is you can establish relationships but have more control over the data. Most frameworks examine foreign keys, but there are lots of times I want to move things around in a way that would not necessarily be expected. Non-enforced FK's allow me to do that while still letting the ORM know there's an object relationship to consider.Jeremy Holovacs

1 Answers

1
votes

In FluentNHibernate, 'NotFound.Ignore()' might do what you need, eg:

References(x => x.Parent).NotFound.Ignore();