How to set a default value on a Boolean in a Code First model?

asked9 years ago
last updated9 years ago
viewed71.4k times
Up Vote35Down Vote

I have an existing table / model into which I want to drop a new Boolean column. This table already has many hundreds of rows of data, and I can't touch the existing data. But.. This column will NOT be nullable, so I need to provide a default value of true to all the rows that currently exist.

public class Revision
{
    ...
    public Boolean IsReleased { get; set; }
    ....
}

(This was in the OP, but people seemed to miss is.)

When databases are updated with the migration, all existing rows which receive this new column MUST have their values set to True.