Configuring Audit.EntityFramework with the below configuration (part of Audit.Net) does not result in the proper mapping of entities.
Audit.EntityFramework.Configuration.Setup().ForContext<AuditAudiCCPContext>().UseOptOut();
The method
public override object InsertEvent(AuditEvent auditEvent)
of EntityFrameworkDataProvider.cs
returns without any exception because it is unable to find the mapped entity.
Line 96 of EntityFrameworkDataProvider.cs
:
var mappedType = _auditTypeMapper?.Invoke(type, entry);
which attempts to map the entity to the audited entity fails to produce any result.
I tried the following other configurations
a.
Audit.EntityFramework.Configuration.Setup()
.ForContext<AuditAudiCCPContext>(config => config
.ForEntity<SubjectInfo>(_=>_.Ignore(e=>e.Ticket).Ignore(e=>e.LevelSubjectMap))
.AuditEventType("{context}:{database}"))
.UseOptIn();
b. The suggestions in this post -How do I target another database with Audit.Net - Audit.EntityFramework.Core
c. I am unable to use the method UseEntityFramework
on Setup()
because it is unavailable.
It should create an entry in the audit database table, but that does not happen. There are no exceptions either.