The discussion is really old, but I had the same error, I found that discussion, it put me on the way, but required more research to find the solution to my problem, I'll just explain the way I solved my problem.
When you add your own user class to your project, the user class is often rename ApplicationUser, a class that's inheriting the IdentityUser, before making any migration, you have to go in the ApplicationDbContext file, and add it as a generic argument for the context:
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
after that you have always to make some changes in the _LoginPartial.cshtml file (Views > Shared > _LoginPartial.cshtml) in changing these lines :
@using Microsoft.AspNetCore.Identity
@inject SignInManager<IdentityUser> SignInManager
@inject UserManager<IdentityUser> UserManager
by those
@using Microsoft.AspNetCore.Identity
@using YourProjectName.Data
@inject SignInManager<ApplicationUser> SignInManager
@inject UserManager<ApplicationUser> UserManager
Don't forget to replace YourProjectName by the name of your project
After that you must go in the Program.cs File and replace the IdentityUser at line 13 :
builder.Services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
.AddEntityFrameworkStores<ApplicationDbContext>();
remplace the reference to the IdentityUser by the ApplicationUser reference, it should look like that :
builder.Services.AddDefaultIdentity<ApplicationUser>(options => options.SignIn.RequireConfirmedAccount = true)
.AddEntityFrameworkStores<ApplicationDbContext>();
And if you have a Startup.cs file in your project, you should make some changes a well, at line 41 you'll find there the following line :
services.AddDefaultIdentity<IdentityUser>()
.AddDefaultUI(UIFramework.Bootstrap4)
.AddEntityFrameworkStores<ApplicationDbContext>();
replace the instruction by the following :
services.AddIdentity<ApplicationUser, IdentityRole>(options =>
{
options.User.RequireUniqueEmail = false;
})
.AddDefaultUI(UIFramework.Bootstrap4)
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
don't forget to remove spaces between some instructions I pasted, here.
more details in that course, and in the ASP.NET Core Documentation
What I write was Already written, here or other discussion, I just tried to put together all those answers and tried to add some precisions, the link gave by @feihoa really helped me. I hope my answer will help anyone.
Regards.