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)
-
0
- 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
- 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.- 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").
- 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)
- 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.- Ensure the UI column binds to the mapped name:
- In the Blazor Users page column definition, set Field="MyPropertyName" (the exact mapped name).
- 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.
- 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.
-
0
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.