How do I set a default value for a new column usin

2019-08-12 16:03发布

问题:

I know that you can manually manipulate the EF generated migration file to add in the 'defaultValue: 1' parameter to the 'AddColumn' method, but it does not seem to be generating the correct Oracle translation when I look at the generated script.

See my EF migration 'Up' method below:

public override void Up()
    {
        AddColumn("TABLE", "NEW_COLUMN", c => c.Decimal(nullable: false, precision: 10, scale: 0, defaultValue: 1));
    }

And after running 'update-database -script' I get the following corresponding SQL line:

alter table "TABLE" add ("NEW_COLUMN" number(10, 0) not null)

Running this against the database will not set the default value of the existing rows to the desired value of 1... What am I missing here?

I am using EF version 6.0.0.0 and Oracle Managed Data Access version 6.121.2.0