如何使用FluentMigrator删除列?

Mat*_*ius 19 c# migration fluent-migrator .net-4.5

我使用.Net4.5C#,我工作的数据库迁移的一个使用FluentMigrator.我可以使用更改表和添加列

Alter.Table("Items").InSchema("Pricing")
            .AddColumn("CanBe").AsBoolean().NotNullable()
Run Code Online (Sandbox Code Playgroud)

但是我需要删除一些现有的列,并且DeleteColumn也不DropColumnIAlterTableAddColumnOrAlterColumnOrSchemaSyntax接口上也没有方法.

如何使用FluentMigrator删除列?

Mat*_*ius 39

自己找到了:

它必须作为单独的声明.

Alter.Table("Items").InSchema("Pricing")
        .AddColumn("CanBe").AsBoolean().NotNullable();

Delete.Column("AllowSubscription").FromTable("Items").InSchema("Pricing");
Run Code Online (Sandbox Code Playgroud)

  • 遗憾的是,“Alter.Table”中没有“.DeleteColumn”选项:( (5认同)
  • @卡尔托确实如此。我认为这是因为它被“翻译”成了 SQL 语句。 (2认同)