EntityFramework Code First FluentAPI DefaultValue in EF6.X

c#, ef-code-first, ef-fluent-api, entity-framework

Solution

Good news, code first now supports this. In the "Up()" method of the generated migration, specify a default with the following syntax:

AddColumn("[table name]", "[column name]", c => c.Boolean(nullable: false, defaultValue: false));

MSDN for "AddColumn" method

Problem

How can I set the default value using EntityFramework Code First FluentAPI for bool property? Something like: ``` Property(l => l.PropertyFlag).HasColumnType("bit").DefaultValue(1); ```

Original source

Related problems