Exemple #1
0
        /// <summary>
        /// Adds an operation to create an index.
        /// </summary>
        /// <param name="table">The name of the table to create the index on. Schema name is optional, if no
        ///     schema is specified then dbo is assumed.</param>
        /// <param name="columns">The names of the columns to create the index on.</param>
        /// <param name="unique">A value indicating if this is a unique index. If no value is supplied a non-unique
        ///     index will be created.</param>
        /// <param name="name">The name to use for the index in the database. If no value is supplied a unique
        ///     name will be generated.</param>
        /// <param name="clustered">A value indicating whether or not this is a clustered index.</param>
        /// <param name="anonymousArguments">Additional arguments that may be processed by providers. Use anonymous type syntax
        ///     to specify arguments e.g. 'new { SampleArgument = "MyValue" }'.</param>
        public void AddIndex(string table, string[] columns, bool unique = false, string name = null, bool clustered = false, object anonymousArguments = null)
        {
            DbMigration dbMigration = new DbMigration();

            dbMigration.CreateIndex(table, columns, unique, name, clustered, anonymousArguments);
            Sql(dbMigration.GetMigrationSql(SqlConnection));
        }