private static void SetCommonColumnOptions(ColumnConfig source, SqlColumn target)
 {
     SetProperty.IfProvidedNotEmpty <string>(source, nameof(target.ColumnName), value => target.ColumnName = value);
     SetProperty.IfProvided <string>(source, nameof(target.DataType), value => target.SetDataTypeFromConfigString(value));
     SetProperty.IfProvided <bool>(source, nameof(target.AllowNull), value => target.AllowNull  = value);
     SetProperty.IfProvided <int>(source, nameof(target.DataLength), value => target.DataLength = value);
     SetProperty.IfProvided <bool>(source, nameof(target.NonClusteredIndex), value => target.NonClusteredIndex = value);
 }
        private void ReadMiscColumnOptions(MSSqlServerConfigurationSection config, ColumnOptions columnOptions)
        {
            SetProperty.IfProvided <bool>(config, nameof(columnOptions.DisableTriggers), value => columnOptions.DisableTriggers = value);
            SetProperty.IfProvided <bool>(config, nameof(columnOptions.ClusteredColumnstoreIndex), value => columnOptions.ClusteredColumnstoreIndex = value);

            string pkName = null;

            SetProperty.IfProvidedNotEmpty <string>(config, "PrimaryKeyColumnName", value => pkName = value);
            if (pkName != null)
            {
                if (columnOptions.ClusteredColumnstoreIndex)
                {
                    throw new ArgumentException("SQL Clustered Columnstore Indexes and primary key constraints are mutually exclusive.");
                }

                foreach (var standardCol in columnOptions.Store)
                {
                    var stdColOpts = columnOptions.GetStandardColumnOptions(standardCol);
                    if (pkName.Equals(stdColOpts.ColumnName, StringComparison.InvariantCultureIgnoreCase))
                    {
                        columnOptions.PrimaryKey = stdColOpts;
                        break;
                    }
                }

                if (columnOptions.PrimaryKey == null && columnOptions.AdditionalColumns != null)
                {
                    foreach (var col in columnOptions.AdditionalColumns)
                    {
                        if (pkName.Equals(col.ColumnName, StringComparison.InvariantCultureIgnoreCase))
                        {
                            columnOptions.PrimaryKey = col;
                            break;
                        }
                    }
                }

                if (columnOptions.PrimaryKey == null)
                {
                    throw new ArgumentException($"Could not match the configured primary key column name \"{pkName}\" with a data column in the table.");
                }
            }
        }