1

NB. This is not a question on how to get in the default value using other approaches. I'm just curious why the attribute doesn't seem to influence the up-migration code.

I've altered my class by adding the attribute for default value like this. But the addition doesn't seem to come through in the up code.

public class Thing
{
  [Key] public Guid Id { get; set; }
  [DefaultValue("Boom")] public string Info { get; set; }
}

public override void Up()
{
  AddColumn("dbo.Things", "Info", c => c.String());
}

I was expecting something like this answer presents.

public override void Up()
{
  AddColumn("dbo.Things", "Info", c => c.String(defaultValue: "Boom"));
}

Isn't the attribute in effect? Deprecated? Not for Code First migrations?

Community
  • 1
  • 1
Konrad Viltersten
  • 36,151
  • 76
  • 250
  • 438

0 Answers0