Skip to content

Instantly share code, notes, and snippets.

@conwid
Last active May 16, 2023 16:43
Show Gist options
  • Save conwid/fd3eeca89be84610f98fa6a3bc6185d1 to your computer and use it in GitHub Desktop.
Save conwid/fd3eeca89be84610f98fa6a3bc6185d1 to your computer and use it in GitHub Desktop.
Data model extensions
The first demo shows how to extend the user information stored in the database.
public class ApplicationUser : IdentityUser
{
public DateTime DateOfBirth { get; set; }
}
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext(DbContextOptions options) : base(options)
{
}
}
builder.Services.AddDbContext<ApplicationDbContext>(opts => opts.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=IdentityDemo;Integrated Security=true"));
builder.Services.AddIdentity<ApplicationUser, IdentityRole>();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment