I am trying to create a database scripter tool for the local database that I am using.
I managed to create creation scripts for tables, primary keys, indexes, and foreign keys, but I cannot find a way to generate creation scripts for table defaults.
For indices, it's just like
foreach (Index index in table.Indexes) { ScriptingOptions drop = new ScriptingOptions(); drop.ScriptDrops = true; drop.IncludeIfNotExists = true; foreach (string dropstring in index.Script(drop)) { createScript.Append(dropstring); } ScriptingOptions create = new ScriptingOptions(); create.IncludeIfNotExists = true; foreach (string createstring in index.Script(create)) { createScript.Append(createstring); } }
But the Table object does not have the Defaults property. Is there any other way to generate scripts for tabular defaults?
source share