I'm creating a Profile for a user, adding columns to ApplicationUser and then executing the DbSet command at ApplicationDbContext. Just writing the DbSet command, it will throw an error:
InvalidOperationException: Unable to materialize entity instance of type 'IdentityUser'. No discriminators matched the discriminator value ''.
What did I do wrong and where? How can I fix it? Just dropping DbSet at ApplicationDbContex, everything can run normally.
Code of the ApplicationUser:
public class ApplicationUser : IdentityUser
{
[Display(Name = "Full Name")] public string FullName { get; set; }
public DateTime CreateAt { get; set; }
public DateTime? UpdateAt { get; set; }
public string ImagePath { get; set; }
public ApplicationUser()
{
CreateAt = DateTime.Now;
UpdateAt = DateTime.Now;
}
}
The ApplicationDbConText:
public class ApplicationDbContext : IdentityDbContext
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}
public DbSet<ApplicationUser> ApplicationUsers { get; set; }
}
