abp.io - extend user profile

1.1k Views Asked by At

Working with abp.io (free framework version), how to add custom properties to User profile ? Such a BirthDate, Gender etc.

I saw this doc about ExtraProperties, but it does not explain when/how to use it, and I'd rather have a Custom User class with my properties :

https://docs.abp.io/en/abp/5.0/Object-Extensions

I saw another doc stating that you want to extend the "AppUser" class, but in my template (v5.0-rc), there is no such a class in the *.Domain project.

What would be the "preferred" way ?

2

There are 2 best solutions below

1
On

A separate article will be written for this soon, but until then, you can read the parts of this article after the "The AppUser Entity & Custom Properties" heading.

On GitHub: https://github.com/abpframework/abp/blob/dev/docs/en/Community-Articles/2021-05-24-Removing-EfCore-Migrations/POST.md#the-appuser-entity--custom-properties

On Community: https://community.abp.io/articles/unifying-dbcontexts-for-ef-core-removing-the-ef-core-migrations-project-nsyhrtna

Also, this article shows how you can query on custom properties added under the heading "Querying Based on a Custom Property".

In fact, as you will see, the absence of AppUser means almost nothing. Almost all the written codes are the same :)

0
On
        Type myType = tenantDto.TenantSettings.GetType();
        IList<PropertyInfo> props = new List<PropertyInfo>(myType.GetProperties());
        foreach (PropertyInfo prop in props)
        {
            tenantDto.ExtraProperties.Add(prop.Name,prop.GetValue(tenantDto.TenantSettings,null;

        }