コード例 #1
0
        /// <summary>
        /// Adds an operation to create a new primary key.
        /// </summary>
        /// <param name="table">The table that contains the primary key column. Schema name is optional, if no
        ///     schema is specified then dbo is assumed.</param>
        /// <param name="columns">The primary key columns.</param>
        /// <param name="name">The name of the primary key 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 primary key.</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 AddPrimaryKey(string table, string[] columns, string name = null, bool clustered = true, object anonymousArguments = null)
        {
            DbMigration dbMigration = new DbMigration();

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