How can I alter column in fluent migration with default date time value that is current date time?
So I need smth like this:
ALTER TABLE database ADD column DATETIME DEFAULT GETDATE() NOT NULL;
only for fluent migration. Thanks.
Seeing as the answer doesn't actually include any code:
Create.Table(nameof(Report))
.WithColumn(nameof(Report.Id)).AsInt32().NotNullable().PrimaryKey().Identity()
.WithColumn(nameof(Report.CreatedAt)).AsDateTime().Nullable()
.WithDefault(SystemMethods.CurrentDateTime);
The WithDefault(SystemMethods)
method is the solution.