Frage

I get SqlCeException ... The column cannot contain null values. [ Column name = Subtotal when I run the following Entity Framework migration.

public override void Up()
{
    AlterColumn("BuildingOrders", "Subtotal",
        c => c.Decimal(nullable: false, precision: 18, scale: 2));
}

Is this the right way to set the default value? It seems too easy :)

public override void Up()
{
    AlterColumn("BuildingOrders", "Subtotal",
        c => c.Decimal(nullable: false, precision: 18, scale: 2, defaultValue: 0));
}

I tried this after seeing a similar question for ruby on rails.

Keine korrekte Lösung

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top