BEST
DEALS
OF THE
YEAR!
SAVE UP TO $3,000
LAST DAY 1 DEC
00 Days
00 Hrs
00 Min
00 Sec
Open Closed

Issues with extended IdentityUser properties: grid sorting error and create form visibility ignored #10140


User avatar
0
FelixKirschner created

Hello, I extended dbo.AbpUsers / IdentityUser with two additional properties following this ABP tutorial: https://abp.io/community/articles/identityuser-relationship-and-extending-it-xtv79mpx#gsc.tab=0 The database and entities were extended successfully. However, I am seeing two issues:

1) Grid sorting error When I click on the column header for the custom property (e.g. MyField) in the user grid, the backend throws an exception:

No property or field 'MyField' exists in type 'IdentityUser' No property or field 'MyField' exists in type 'IdentityUser' (at index 0) at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseMemberAccess(Type type, Expression expression, String id) ... at Volo.Abp.Identity.EntityFrameworkCore.EfCoreIdentityUserRepository.GetListAsync(String sorting, Int32 maxResultCount, Int32 skipCount, String filter, Boolean includeDetails, Nullable1 roleId, Nullable1 organizationUnitId, String userName, String phoneNumber, String emailAddress, String name, String surname, Nullable1 isLockedOut, Nullable1 notActive, Nullable1 emailConfirmed, Nullable1 isExternal, Nullable1 maxCreationTime, Nullable1 minCreationTime, Nullable1 maxModifitionTime, Nullable1 minModifitionTime, CancellationToken cancellationToken)

It looks like the dynamic sorting (OrderBy) is executed against IdentityUser and not against the extended type / object extension, so the property cannot be found.

2) UI visibility for create form is ignored For one of the custom properties I tried to hide it on the create form and only show it in the table. I configured the extension like this:

ObjectExtensionManager.Instance.Modules().ConfigureIdentity(identity =>
{
    identity.ConfigureUser(user =>
    {
        user.AddOrUpdateProperty<Guid?>(
            MyConsts.MyPropertyName,
            options =>
            {
                options.DefaultValue = null;
                options.UI.OnTable.IsVisible = true;
                options.UI.OnCreateForm.IsVisible = false;
            }
        );
    });
});

If there is a preferred approach to enable sorting for extended IdentityUser properties and to manage their visibility on the create form, I would appreciate any guidance or documentation updates.


2 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    1. Solution
    • Why sorting fails
      • The Users page sends a dynamic sorting string (e.g., MyField asc) to EfCoreIdentityUserRepository.GetListAsync, which uses System.Linq.Dynamic.Core to apply OrderBy on IQueryable<IdentityUser>. If your extra property is only defined as an object extension (extraProperties JSON) and not mapped as an EF Core property on the entity (shadow property), OrderBy can’t find the member on IdentityUser and throws “No property or field ‘MyField’ exists...”.
    • Fix sorting for extended properties
      1. Map the extra property to a real EF Core property on IdentityUser so it becomes a model member EF can translate and Dynamic LINQ can OrderBy:
    // In YourProjectNameEfCoreEntityExtensionMappings.Configure()
         ObjectExtensionManager.Instance
             .MapEfCoreProperty<IdentityUser, string>(
                 MyConsts.MyPropertyName,
                 (entityBuilder, propertyBuilder) =>
                 {
                     propertyBuilder.HasMaxLength(128);
                     // optional: propertyBuilder.HasDefaultValue("");
                     // optional: add index/unique/etc.
                 }
             );
    
     - Ensure this mapping executes before DbContext model building (use the generated EfCoreEntityExtensionMappings class).
     - Add a migration and update the database.
    
    1. If you already mapped it, ensure the sorting header sends the exact mapped property name (case-sensitive for Dynamic LINQ) and not a display text. For Blazor data table columns, set Field to the exact member name used in MapEfCoreProperty (e.g., "MyPropertyName").
    2. If you intentionally keep the value only in ExtraProperties (JSON field), you can’t dynamically OrderBy that member directly. In that case, either:
      • Project to a DTO with a computed column and sort in memory after materialization (not recommended for paging/large data), or
      • Create a database computed column and map it via MapEfCoreProperty, then sort by that mapped property.
    • UI visibility OnCreateForm ignored (Blazor Server)
      • ABP’s module entity extension UI configuration supports per-surface visibility:
    ObjectExtensionManager.Instance.Modules().ConfigureIdentity(identity =>
        {
            identity.ConfigureUser(user =>
            {
                user.AddOrUpdateProperty<Guid?>(
                    MyConsts.MyPropertyName,
                    options =>
                    {
                        options.DefaultValue = null;
                        options.UI.OnTable.IsVisible = true;
                        options.UI.OnCreateForm.IsVisible = false;
                        // optionally:
                        // options.UI.OnEditForm.IsVisible = true;
                    }
                );
            });
        });
    
    • Notes:

      • This only affects the auto-generated extension-props part of the form. If you have overridden the Identity Users Blazor page/components, your override can re-render properties regardless of the flags.
      • If the property is required and hidden on create, you will get validation errors on save. Use a default value, make it optional for create, or set a server-side default.
      • Ensure your extension configuration runs in the Domain.Shared module (or a module loaded before UI) and only once. A common pattern is using OneTimeRunner.
      • If it still appears, clear the UI cache and ensure you’re not customizing the user page. For customized pages, move or remove the property manually in your razor/partial.
    • End-to-end checklist for your case (ABP 9.1.3, Blazor Server, SQL Server)

      1. Ensure EF Core mapping exists for sorting:
    // Domain.EfCore project
         public static class YourProjectEfCoreEntityExtensionMappings
         {
             private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
    
             public static void Configure()
             {
                 OneTimeRunner.Run(() =>
                 {
                     ObjectExtensionManager.Instance
                         .MapEfCoreProperty<IdentityUser, string>(
                             MyConsts.MyPropertyName,
                             (_, p) =>
                             {
                                 p.HasMaxLength(128);
                             }
                         );
                 });
             }
         }
    
     - Call YourProjectEfCoreEntityExtensionMappings.Configure() during pre-DbContext configuration (usually in your EntityFrameworkCore module’s ConfigureServices).
     - Run Add-Migration and Update-Database.
    
    1. Ensure the UI column binds to the mapped name:
      • In the Blazor Users page column definition, set Field="MyPropertyName" (the exact mapped name).
    2. Keep/create form visibility:
      • Keep your existing options.UI flags as shown above.
      • If the property is still visible on create, check for a local override of UserManagement page. If overridden, adjust the layout to respect IsVisible or remove the property from the create form section.
    1. Sources
    • https://abp.io/docs/latest/framework/architecture/modularity/extending/customizing-application-modules-extending-entities
    • https://abp.io/docs/latest/framework/fundamentals/object-extensions
    • https://abp.io/docs/latest/framework/architecture/modularity/extending/module-entity-extensions
    • https://abp.io/docs/latest/framework/data/entity-framework-core/

    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    If you're trying to do this for the ExtraProperties field in the database, you can't. Because the properties set in the ExtraProperties field are stored as a single JSON object.

    However, you can refer to this document which explains the more natural way to do it.

    https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Extending-Entities#entity-extensions-ef-core

    If you have already mapped the property to ef core as stated in the document, you can use the query, below. Because the property you add is kept as a separate column in the database table.

    var query = (await GetQueryableAsync()).Where(u => EF.Property<string>(u, "SocialSecurityNumber") == "123");
    

    Thanks.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.1.0-preview. Updated on November 20, 2025, 09:12
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.