You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When extending DateTime? or Guid? property for entity ,can not save success.
(Guid? Property)stack trace:
System.InvalidCastException: Object must implement IConvertible.
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at Volo.Abp.EntityFrameworkCore.AbpDbContext1.HandleExtraPropertiesOnSave(EntityEntry entry) at Volo.Abp.EntityFrameworkCore.AbpDbContext1.ApplyAbpConcepts(EntityEntry entry, EntityChangeReport changeReport)
at Volo.Abp.EntityFrameworkCore.AbpDbContext1.ApplyAbpConcepts() at Volo.Abp.EntityFrameworkCore.AbpDbContext1.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
at Volo.Abp.Domain.Repositories.EntityFrameworkCore.EfCoreRepository`2.UpdateAsync(TEntity entity, Boolean autoSave, CancellationToken cancellationToken)
(DateTime? Property)stack trace:
System.InvalidCastException: Invalid cast from 'System.DateTime' to 'System.Nullable1[[System.DateTime, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]'. at System.Convert.DefaultToType(IConvertible value, Type targetType, IFormatProvider provider) at System.DateTime.System.IConvertible.ToType(Type type, IFormatProvider provider) at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) at Volo.Abp.EntityFrameworkCore.AbpDbContext1.HandleExtraPropertiesOnSave(EntityEntry entry)
at Volo.Abp.EntityFrameworkCore.AbpDbContext1.ApplyAbpConcepts(EntityEntry entry, EntityChangeReport changeReport) at Volo.Abp.EntityFrameworkCore.AbpDbContext1.ApplyAbpConcepts()
at Volo.Abp.EntityFrameworkCore.AbpDbContext1.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) at Volo.Abp.Domain.Repositories.EntityFrameworkCore.EfCoreRepository2.UpdateAsync(TEntity entity, Boolean autoSave, CancellationToken cancellationToken)
Reproduce steps:
Setp1.Add extra properties to AppUser
public virtual Guid? NullableGuidProperty { get; set; }
public virtual DateTime? NullableDateTimeProperty { get; set; }
Setp2. Config in EfCoreEntityExtensionMappings file
When extending DateTime? or Guid? property for entity ,can not save success.
(Guid? Property)stack trace:
System.InvalidCastException: Object must implement IConvertible.
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at Volo.Abp.EntityFrameworkCore.AbpDbContext
1.HandleExtraPropertiesOnSave(EntityEntry entry) at Volo.Abp.EntityFrameworkCore.AbpDbContext
1.ApplyAbpConcepts(EntityEntry entry, EntityChangeReport changeReport)at Volo.Abp.EntityFrameworkCore.AbpDbContext
1.ApplyAbpConcepts() at Volo.Abp.EntityFrameworkCore.AbpDbContext
1.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)at Volo.Abp.Domain.Repositories.EntityFrameworkCore.EfCoreRepository`2.UpdateAsync(TEntity entity, Boolean autoSave, CancellationToken cancellationToken)
(DateTime? Property)stack trace:
System.InvalidCastException: Invalid cast from 'System.DateTime' to 'System.Nullable
1[[System.DateTime, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]'. at System.Convert.DefaultToType(IConvertible value, Type targetType, IFormatProvider provider) at System.DateTime.System.IConvertible.ToType(Type type, IFormatProvider provider) at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) at Volo.Abp.EntityFrameworkCore.AbpDbContext
1.HandleExtraPropertiesOnSave(EntityEntry entry)at Volo.Abp.EntityFrameworkCore.AbpDbContext
1.ApplyAbpConcepts(EntityEntry entry, EntityChangeReport changeReport) at Volo.Abp.EntityFrameworkCore.AbpDbContext
1.ApplyAbpConcepts()at Volo.Abp.EntityFrameworkCore.AbpDbContext
1.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) at Volo.Abp.Domain.Repositories.EntityFrameworkCore.EfCoreRepository
2.UpdateAsync(TEntity entity, Boolean autoSave, CancellationToken cancellationToken)Reproduce steps:
Setp1.Add extra properties to AppUser
public virtual Guid? NullableGuidProperty { get; set; }
public virtual DateTime? NullableDateTimeProperty { get; set; }
Setp2. Config in EfCoreEntityExtensionMappings file
ObjectExtensionManager.Instance .MapEfCoreProperty<IdentityUser, Guid?>("NullableGuidProperty");
ObjectExtensionManager.Instance.MapEfCoreProperty<IdentityUser, DateTime?>("NullableDateTimeProperty");
Setp3.Update User
var user = await UserManager.GetByIdAsync(id);
user.SetProperty("NullableDateTimeProperty", DateTime.Now);
user.SetProperty("NullableGuidProperty", GuidGenerator.Create());
await _userRepository.UpdateAsync(user, true);
The text was updated successfully, but these errors were encountered: