'ABP Validation from User Entity Extension

ABP v4.4.4
I've added a few fields to User entity to MyProjectIdentityEfCoreEntityExtensionMappings.cs:

ObjectExtensionManager.Instance
    .MapEfCoreProperty<IdentityUser, Gender?>(UserExtensionNames.Gender)
    .MapEfCoreProperty<IdentityUser, UserStatus>(UserExtensionNames.UserStatus);

Before even attempting to add extension to IdentityUserCreateDto, I tried calling the create user endpoint /api/identity/users, and I'm hit with validation errors as below. 2 things I've taken note here:

  1. Validation error for the nullable field is prompted
  2. The non-nullable field validation error appeared twice.

2022-01-28 16:39:09.089 +08:00 [WRN] ModelState is not valid! See ValidationErrors for details. Volo.Abp.Validation.AbpValidationException: ModelState is not valid! See ValidationErrors for details. at Volo.Abp.AspNetCore.Mvc.Validation.ModelStateValidator.Validate(ModelStateDictionary modelState) at Volo.Abp.AspNetCore.Mvc.Validation.AbpValidationActionFilter.OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
2022-01-28 16:39:09.090 +08:00 [WRN] There are 3 validation errors:
The Gender field is required. (Gender)
The UserStatus field is required. (UserStatus)
The UserStatus field is required. (UserStatus)

2022-01-28 16:39:09.094 +08:00 [INF] Executing ObjectResult, writing value of type 'Volo.Abp.Http.RemoteServiceErrorResponse'. 2022-01-28 16:39:09.102 +08:00 [INF] Executed action Volo.Abp.Identity.IdentityUserController.CreateAsync (Volo.Abp.Identity.HttpApi) in 309.3593ms 2022-01-28 16:39:09.102 +08:00 [INF] Executed endpoint 'Volo.Abp.Identity.IdentityUserController.CreateAsync (Volo.Abp.Identity.HttpApi)'

My expected result is there should be 1 validation error for UserStatus field.
Anyone can share some light on what is going on?
Thanks in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source