bubibubi / sqliteef6migrations

System.Data.SQLite.EntityFramework.Migrations - Migrations for SQLite Entity Framework provider
Microsoft Public License
40 stars 20 forks source link

Add support for more data types when adding a new column with default value #19

Open dtphan opened 2 years ago

dtphan commented 2 years ago

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.