Skip to content

Conversation

dtphan
Copy link

@dtphan dtphan commented Feb 22, 2022

When I tried to add a new column with a default value, the default value was not included in the SQL statement. For example,

public override void Up()
{
    AddColumn("dbo.TestTable", "ExtraColumn", c => c.Int(nullable: false, defaultValue: 1));
}

The generated SQL would be "ALTER TABLE "TestTable" ADD COLUMN "ExtraColumn"int not null"
If the table already has some data in it, there would be an error during migration: "Cannot add a NOT NULL column with default value NULL"

This pull request adds support for more data types for the default value other than DateTime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant