【发布时间】:2026-02-06 14:45:01
【问题描述】:
我有一个表,其中有一列 [CreatedAtIsoUtc] 设置了 Sql Server 默认值
migrationBuilder.CreateTable(
name: "CurrentAccountLedger",
columns: table => new
{
Id = table.Column<Guid>(nullable: false, defaultValueSql: "newsequentialid()"),
CreatedAtIsoUtc = table.Column<DateTime>(nullable: false, defaultValueSql: "GETUTCDATE()"),
}
});
在原始 sql server 查询中,我可以插入一条记录并覆盖 [CreatedAtIsoUtc] 默认值。
在实体框架中,执行 Add() 操作时,我似乎无法覆盖此值。
关于如何让这个工作的任何想法?
【问题讨论】:
标签: entity-framework entity-framework-core