Abp.EntityHistory.EntityHistoryHelperBase.IsAuditedPropertyInfo: Object reference not set ...
See original GitHub issueHi community 😃 I’ve problem with auditing exception for PropertyInfo object. Abp version 6.4.0 .NetCore 5
Exeption
Object reference not set to an instance of an object
at Abp.EntityHistory.EntityHistoryHelperBase.IsAuditedPropertyInfo(PropertyInfo propertyInfo) at Abp.EntityHistory.EntityHistoryHelper.GetPropertyChanges(EntityEntry entityEntry, Boolean auditedPropertiesOnly) at Abp.EntityHistory.EntityHistoryHelper.CreateEntityChangeSet(ICollection
1 entityEntries) at Abp.Zero.EntityFrameworkCore.AbpZeroCommonDbContext
3.<SaveChangesAsync>d__130.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.<SaveChangesAsync>d__12.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Authorization.Users.AbpUserStore2.<>c__DisplayClass46_0.<<CreateAsync>b__0>d.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable
1.ConfiguredTaskAwaiter.GetResult() at Abp.Domain.Uow.UnitOfWorkManagerExtensions.<WithUnitOfWorkAsync>d__31.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable
1.ConfiguredTaskAwaiter.GetResult() at Abp.Authorization.Users.AbpUserStore2.<CreateAsync>d__46.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter
1.GetResult() at Microsoft.AspNetCore.Identity.UserManager1.<CreateAsync>d__73.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable
1.ConfiguredTaskAwaiter.GetResult() at Abp.Authorization.Users.AbpUserManager2.<CreateAsync>d__37.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter
1.GetResult() at Microsoft.AspNetCore.Identity.UserManager1.<CreateAsync>d__78.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter
1.GetResult()
I’ve readed in EFCore documentation
/// <summary> /// Gets the <see cref="PropertyInfo" /> for the underlying CLR property that this /// object represents. This may be null for shadow properties or properties mapped directly to fields. /// </summary> PropertyInfo PropertyInfo { get; }
and that is a problem, because my entity looks this:
private string _gender;
[NotMapped]
[DisableAuditing]
public GenderEnum Gender { get => GenderEnum.Parse(_gender); set => _gender = value?.Value; }
- [DisableAuditing] not help
- I use [NotMapped] attribute because propery is mapped to encapsulated filed and GenderEnum class is not a EF table object
public class UserEntityTypeConfiguration : IEntityTypeConfiguration<User>
{
public void Configure(EntityTypeBuilder<User> builder)
{
builder.Property<string>("_gender").HasColumnName("Gender");
}
}
` - When i change my entity to
public string Gender { get; set; }
without explicitly encapsulation EntityHistoryHelper doesn’t throw any errors.
So i thing we have a problem with PropertyInfo = null
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (5 by maintainers)
@1jedrzej1 thanks, we will check this.
@ahmedtolba1984 we will test this again.