private void AddCreateUniqueConstraintBatch(Index index, QuoteType quoteType) { List <ColumnWithSortOrder> columns = new List <ColumnWithSortOrder>(); foreach (var member in index.Members) { Column column = index.Parent.Columns.FirstOrDefault(c => c.Name == member.Column); columns.Add( ScriptFactory.ColumnWithSortOrder( ScriptFactory.ColumnReferenceExpression( ScriptFactory.MultiPartIdentifier( ScriptFactory.Identifier(member.Column, quoteType)), ColumnType.Regular), SortOrder.Ascending)); } UniqueConstraintDefinition uniqueConstraint = ScriptFactory.UniqueConstraintDefinition( ScriptFactory.Identifier(index.Name, quoteType), false, index.IsClustered, null, null, null, columns ); AddBatch(ScriptFactory.AlterTableAddTableElement( ScriptFactory.TableDefinition( null, null, new List <ConstraintDefinition> { uniqueConstraint }, null), Generator.GenerateSchemaObjectName(index.Parent, quoteType))); }