Hi,
I have updated User entity to have an address.
When I update the address or create user I get NullReferenceException in the Abp.ZeroCore.EntityFrameworkCore.dll when executing CheckErrors(await UserManager.UpdateAsync(user));
from UserAppService
When I change anything else in the User (standard properties) and do not change the user I get not errors! Happens only when I change my extended User properties
Also the HomeAddress is not null not the properties in the instance of HomeAddress
Here is how the User class looks like:
/// <summary>
/// Represents a user in the system.
/// </summary>
public class User : AbpUser<User>
{
public virtual Guid? ProfilePictureId { get; set; }
public virtual bool ShouldChangePasswordOnNextLogin { get; set; }
public DateTime? SignInTokenExpireTimeUtc { get; set; }
public string SignInToken { get; set; }
public string GoogleAuthenticatorKey { get; set; }
//Can add application specific user properties here
public PlasticsTrader.Crm.Address HomeAddress { get; set; }
public User()
{
IsLockoutEnabled = true;
IsTwoFactorEnabled = true;
}
/// <summary>
/// Creates admin <see cref="User"/> for a tenant.
/// </summary>
/// <param name="tenantId">Tenant Id</param>
/// <param name="emailAddress">Email address</param>
/// <returns>Created <see cref="User"/> object</returns>
public static User CreateTenantAdminUser(int tenantId, string emailAddress)
{
var user = new User
{
TenantId = tenantId,
UserName = AdminUserName,
Name = AdminUserName,
Surname = AdminUserName,
EmailAddress = emailAddress,
HomeAddress = new Crm.Address()
};
user.SetNormalizedNames();
return user;
}
public static string CreateRandomPassword()
{
return Guid.NewGuid().ToString("N").Truncate(16);
}
public override void SetNewPasswordResetCode()
{
/* This reset code is intentionally kept short.
* It should be short and easy to enter in a mobile application, where user can not click a link.
*/
PasswordResetCode = Guid.NewGuid().ToString("N").Truncate(10).ToUpperInvariant();
}
public void Unlock()
{
AccessFailedCount = 0;
LockoutEndDateUtc = null;
}
public void SetSignInToken()
{
SignInToken = Guid.NewGuid().ToString();
SignInTokenExpireTimeUtc = Clock.Now.AddMinutes(1).ToUniversalTime();
}
When I disable the EntityHistory Configuration.EntityHistory.IsEnabled = false;
it works
I tried to have it enable but to put
[DisableAuditing]
public PlasticsTrader.Crm.Address HomeAddress { get; set; }
still does not work!
1 Answer(s)
-
0
OK solved the problem.
The whole chain of classes has to be marked Audited or DisableAuditing in order for the EntityHistory to work