Extend application user | Blazor (Blazor)

Add ApplicationUser partial class

  1. Open the solution that Radzen has generated with Visual Studio (or the server directory with Visual Studio Code).
  2. Go to the server\Authentication directory.
  3. Add a new file server\Models\ApplicationUser.Custom.cs with the following content.
    using System;
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations.Schema;
    using System.Runtime.Serialization;
    using Microsoft.AspNetCore.Identity;
    using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
    
    // Replace [ApplicationName] with the namespace of your Radzen application.
    namespace [ApplicationName].Models
    {
        public partial class ApplicationUser
        {
            public string Country { get; set; }
        }
    }
    
  4. Open the server directory in a terminal.
  5. Run dotnet ef migrations add Country -c ApplicationIdentityDbContext. This will create an Entity Framework Core migration which at runtime will add a Country column to the AspNetUsers table. It will store the Country property values.

If you haven’t installed the EF Core tools before that command will fail. Run dotnet tool install --global dotnet-ef to install them.

Extend the user management pages

In order to capture the values of the custom properties created in the previous step you have to update the user management pages.

Check the related article from our CRM application tutorial.