-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Background
Currently this setting is controlled via Dude.EnableAutomaticForeignKeys(...), however quite a few users have misunderstood what the options here means. There are two concepts at play here:
-
Using previous inserts to set FK columns when inserting rows. The default behavior here is to always fill a dependency if it is available and the column value has not been set manually (to null for example). This is enabled by setting
Dude.EnableAutomaticForeignKeys()with no parameters. -
Analysing FK dependencies of tables being inserted to and automatically adding extra inserts where needed, depending on dependency traversal strategy. This is enabled by setting
Dude.EnableAutomaticForeignKeys(c => c.AddMissingForeignKeys = true). It's also possible to set a dependency traversal strategy like this to change from the default strategy or plugging in your own strategy:
Dude.EnableAutomaticForeignKeys(c =>
{
c.AddMissingForeignKeys = true;
c.DependencyTraversalStrategy = DependencyTraversalStrategy.SkipNullableForeignKeys;
}The problem
The confusion however seem to be that the dependency traversal strategy affects whether foreign keys are filled in scenario 1, which is not what it is for. I think this is a failure of the library api, it's not clear enough what the difference is and i think it could be changed to make the distinction clearer.