I have an exsiting entity class, in C#, I'm using code first migration with entity framework core, and I would like to set a default value to my column with data annotation method (I have to use this, I can't use the Fluent API):
[DefaultValue(true)]
public bool? ColumnName { get; set; }
After I run the migration tool, the Up looks like this:
migrationBuilder.AlterColumn<bool>(
name: "ColumName",
schema: "SCHEMA",
table: "TableName",
type: "bit",
nullable: true,
oldClrType: typeof(bool),
oldType: "bit",
oldNullable: true,
oldDefaultValue: true);
How can I solve this problem with Data Annotation?