Search code examples
c#migration.net-4.5fluent-migrator

How to drop column with FluentMigrator?


I am using .Net4.5 and C#, I am working on one of database migrations using FluentMigrator. I am able to alter tables and add columns by using

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

However I need to drop some existing columns and nor DeleteColumn nor DropColumn methods are not on IAlterTableAddColumnOrAlterColumnOrSchemaSyntax interface.

How do I drop columns using FluentMigrator?


Solution

  • Found it myself:

    It has to go as separate statement.

    Alter.Table("Items").InSchema("Pricing")
            .AddColumn("CanBe").AsBoolean().NotNullable();
    
    Delete.Column("AllowSubscription").FromTable("Items").InSchema("Pricing");