【发布时间】:2020-05-09 05:23:58
【问题描述】:
我目前正在使用 EF Core 的 ASP.NET Core Web API 项目中实现 Audit.NET。我正在使用Entity Framework Data Provider,目前已将其配置为使用以下代码将所有实体映射到单个审核日志 (AuditLog) 表。
Audit.Core.Configuration.Setup()
.UseEntityFramework(_ => _
.AuditTypeMapper(t => typeof(AuditLog))
.AuditEntityAction<AuditLog>((ev, entry, audit) =>
{
audit.Date = DateTime.UtcNow;
audit.AuditData = JsonConvert.SerializeObject(entry);
audit.UserIdentifier = userId;
})
.IgnoreMatchedProperties(true));
这很好用,但是,如果实体类型是 Blog,我想将审计条目写入 BlogApprovals 表 - 除了添加到 AuditLog 的条目。因此,对于Blog 实体,我想要both BlogApprovals 和AuditLog 中的审计记录。这可能吗?
【问题讨论】:
标签: entity-framework-core asp.net-core-webapi audit.net