I have a migration adding a column. It’s a not null column, so a default value is need. Per doc it should be added as an attribute:
public class Tag
{
[Default(0)]
public bool Deleted { get; set; }
}
It creates a constraint that adds the default value. It seems the name of it is auto generated, but it’s possible to name it as well, when the column is added:
ADD ExampleName varchar(1) NOT NULL CONSTRAINT DF_ExampleName DEFAULT('w');
which could be useful, because dropping it is necessary to drop the column:
alter table tag drop constraint DF__Tag__Deleted__7132C993
alter table tag drop column Deleted;
migrate.revert:last
crashes because it forgets to remove the constraint/default before the column.