title: SQL SMO is generating insert statements incorrectly
body: <p>I'm working on a C# application to generate the script. I have the following settings below, but tables/insert statements are being generated for other schemas. I just want one specific schema and all the schema/data from it.</p>
  <p>I tried to set <code> options.WithDependencies = false;</code>, but then it wouldn't give me everything I needed as in scripting the data.</p>
  <p>What other setting am I missing?</p>
  <pre><code>        private void GeneratingMainSQLScript(string schema)
          {
              Server srv = new Server(@&quot;.\sql2017&quot;);
              Database dbs = srv.Databases[&quot;SOURCE_T&quot;];
              ScriptingOptions options = new ScriptingOptions();
              options.TargetServerVersion = SqlServerVersion.Version140;
              options.EnforceScriptingOptions = true;
              options.ScriptData = true;
              options.ScriptDrops = false;
              options.FileName = GenerateScriptFileName(schema, false);
              options.EnforceScriptingOptions = true;
              options.ScriptSchema = true;
              options.IncludeHeaders = true;
              options.AppendToFile = true;
              options.Indexes = true;
              options.WithDependencies = true;
  
              var tableNames = GetTableNames(schema);
  
              int progressCounter = 1;
              foreach (var tbl in tableNames)
              {
                  if (tbl.SchemaName == &quot;dbo&quot; &amp;&amp; tbl.TableName == &quot;FileDatas&quot;)
                  {
                      options.ScriptData = false;
                  }
  
                  dbs.Tables[tbl.TableName, tbl.SchemaName].EnumScript(options);
  
                  DisplayDebug(string.Format(&quot;Running migration schema's ({2}) main genreated script | Total: {0} | Processing #: {1}&quot;, tableNames.Count, progressCounter, schema));
  
                  progressCounter++;
              }
          }
  </code></pre>
  <p><em><strong>UPDATE:</strong></em></p>
  <p>I made these changes after working with my lead and we are close. The issue now: it is generating the FKS after creating the table and not at the END of the file like when you do it via SSMS directly?</p>
  <pre><code>Server srv = new Server(@&quot;.\sql2017&quot;);
              Database dbs = srv.Databases[&quot;SOURCE_T&quot;];
              ScriptingOptions options = new ScriptingOptions();
              options.FileName = GenerateScriptFileName(schema, isSchemaOnly);
              options.EnforceScriptingOptions = true;
        
              // start
              options.AnsiPadding = false;
              options.AppendToFile = true;
              options.ContinueScriptingOnError = false;
              options.ConvertUserDefinedDataTypesToBaseType = false;
              options.WithDependencies = false;
              options.IncludeHeaders = true;
              options.IncludeScriptingParametersHeader = false;
              options.SchemaQualify = true;
              options.Bindings = false;
              options.NoCollation = true;
              options.Default = true;
              options.ScriptDrops = false;
              options.ScriptSchema = isSchemaOnly;
              options.ExtendedProperties = true;
              options.TargetServerVersion = SqlServerVersion.Version140;
              options.TargetDatabaseEngineType = Microsoft.SqlServer.Management.Common.DatabaseEngineType.Standalone;
              options.LoginSid = false;
              options.Statistics = false;
              options.ScriptData = !isSchemaOnly;
              options.ChangeTracking = false;
              options.DriAllConstraints = true;
              options.ScriptDataCompression = false;
              options.DriForeignKeys = true;
              options.FullTextIndexes = false;
              options.Indexes = false;
              options.DriPrimaryKey = true;
              options.Triggers = false;
              options.DriUniqueKeys = true;
              options.DriAll = true;
  </code></pre>
  <pre><code>
  </code></pre>