Using MVC jQuery, .NET Core, ABP v3.5.0.
Entity History is enabled: Configuration.EntityHistory.IsEnabled = true;
I inserted some data directly into a table using t-sql. If I then try to update one of those records via the web app, I see an exception thrown:
System.NullReferenceException: Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
at Abp.EntityHistory.EntityHistoryHelper.ShouldSavePropertyHistory(PropertyEntry propertyEntry, Boolean defaultValue) in D:\Github\aspnetboilerplate\src\Abp.ZeroCore.EntityFrameworkCore\EntityHistory\EntityHistoryHelper.cs:line 292
at Abp.EntityHistory.EntityHistoryHelper.GetPropertyChanges(EntityEntry entityEntry) in D:\Github\aspnetboilerplate\src\Abp.ZeroCore.EntityFrameworkCore\EntityHistory\EntityHistoryHelper.cs:line 210
at Abp.EntityHistory.EntityHistoryHelper.CreateEntityChangeInfo(EntityEntry entityEntry) in D:\Github\aspnetboilerplate\src\Abp.ZeroCore.EntityFrameworkCore\EntityHistory\EntityHistoryHelper.cs:line 160
at Abp.EntityHistory.EntityHistoryHelper.CreateEntityChangeSet(ICollection`1 entityEntries) in D:\Github\aspnetboilerplate\src\Abp.ZeroCore.EntityFrameworkCore\EntityHistory\EntityHistoryHelper.cs:line 95
at Abp.Zero.EntityFrameworkCore.AbpZeroCommonDbContext`3.<SaveChangesAsync>d__98.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
I disabled the Entity History and removed the Entity History selector and the updates are now working again for the records inserted directly into the tables using t-sql.
Configuration.EntityHistory.IsEnabled = false;
//Configuration.EntityHistory.Selectors.Add(
// new NamedTypeSelector(
// "Abp.AuditedEntity",
// type => typeof(IAudited).IsAssignableFrom(type)
// )
//);
Is the Entity History feature dependent upon the data having to be inserted via the web app?
Is the Entity History feature dependent upon the data having to be inserted via the web app?
No.
This has been fixed in ABP v3.6.0: #3314
As the documentation says
PropertyInfo
can be null for shadow properties or properties mapped directly to fields.
Essentially, this involved a null
check in EntityHistoryHelper.cs:
// if (propertyInfo.IsDefined(typeof(DisableAuditingAttribute), true))
if (propertyInfo != null &&
propertyInfo.IsDefined(typeof(DisableAuditingAttribute), true))