Add Custom Properties To User Table - bondaigames/ASP.NET-Core-Documentation GitHub Wiki
- Create ApplicationUser.cs file in Models folder
using Microsoft.AspNetCore.Identity;
namespace Services.AuthAPI.Models
{
public class ApplicationUser : IdentityUser
{
public string Name { get; set; }
}
}
builder.Services.AddIdentity<ApplicationUser, IdentityRole>().AddEntityFrameworkStores<AppDbContext>()
.AddDefaultTokenProviders();
using Services.AuthAPI.Models;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
namespace Services.AuthAPI.Data
{
public class AppDbContext : IdentityDbContext<ApplicationUser>
{
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
{
}
public DbSet<ApplicationUser> ApplicationUsers { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
}
}
}
add-migration AddNameToAspNetUsers
update-database