This project is read-only.
1
Vote

ForeignKeys are always scripted as Drops

description

When scripting foreign keys, the code is
 
                            if (!_CreateOnly)
                            {
                                so.ScriptDrops = so.IncludeIfNotExists = true;
                            }
                            WriteScript(smo.Script(), sw);
 
but I think that it should be
 
                            if (!_CreateOnly)
                            {
                                so.ScriptDrops = so.IncludeIfNotExists = true;
                                WriteScript(smo.Script(so), sw);
                            }
                            so.ScriptDrops = so.IncludeIfNotExists = false;
                            WriteScript(smo.Script(so), sw);
 
Currently, drop scripts are always generated which is not very useful.

comments

AndreasPaulsson wrote Sep 28, 2010 at 10:33 PM

By bad, so.DriForeignKeys = true also needs to be set.
                    so.DriForeignKeys = true;
before foreign key script generation and
                    so.DriForeignKeys = false;
is much better.

wrote Feb 14, 2013 at 8:14 PM