NullReferenceException at Audit.PostSaveChanges (v1.4.18+)
We are getting the following error when moving to any of the v1.4.18+ releases (v1.4.17 is working perfectly). Haven't had a chance to dig into this but could be a side effect of #101.
System.NullReferenceException: Object reference not set to an instance of an object.
at Z.EntityFramework.Plus.Audit.PostSaveChanges(Audit audit)
at Z.EntityFramework.Plus.AuditExtensions.SaveChanges(DbContext context, Audit audit)
at ContextWrapper.SaveChanges()
...
AuditConfiguration
// ... ommited ...
AuditManager.DefaultConfiguration.IgnorePropertyUnchanged = true;
AuditManager.DefaultConfiguration.AutoSavePreAction =
(context, audit) =>
{
var auditContext = services.BuildServiceProvider().GetRequiredService<AuditDbContext>();
audit.Entries.ForEach(e =>e.Properties.RemoveAll(p => Equals(p.NewValue, p.OldValue)));
audit.Entries.RemoveAll(e => e.Properties.Count == 0);
auditContext.AddRange(audit.Entries
.Where(x => x.AuditEntryID == 0));
auditContext.SaveChanges();
};
ContextWrapper.SaveChanges
// ... ommited ...
Z.EntityFramework.Plus.Audit audit = new Z.EntityFramework.Plus.Audit();
audit.CreatedBy = "zzz";
return ctx .SaveChanges(audit);
Framework
> dotnet
Microsoft .NET Core Shared Framework Host
Version : 1.1.0
Build : 928f77c4bc3f49d892459992fb6e1d5542cb5e86
> dotnet --version
1.0.0-preview2-1-003177
Hello @TrplM ,
Thank you for reporting this issue. We will try to look at it this week.
Best Regards,
Jonathan
Hello @TrplM ,
The v1.4.23 has been released. We fixed an issue with Audit for EF Core. I'm not exactly sure if that was the same issue but I'm pretty sure it was.
Let me know if that version is working.
Best Regards,
Jonathan
Thanks @JonathanMagnan
We have tested v1.4.23 and the issue has been resolved.
Regards
I'm having the same issue in 1.6.8. It's not constant. It disappears if you restart the server and then comes back after some time.
Hello @ctrl-brk ,
Please, could you open a new issue and reference this one using #108 (the issue number)? It makes easier to track new issue.
Best Regards,
Jonathan