I'm not sure what I did, but I seem to have messed up my ASP.NET Core Identity. It was working. I was able to create an account and login. But now I can't log in, and the Forgot Password function won't send me an email. Some tests indicated UserManager.FindByNameAsync()
was returning null
when there was data matching the request.
I'm getting some strange results as I try to debug this. The following line returns all the Goal
s in my database.
var goals = DbContext.Goals.AsEnumerable();
However, the following line returns an empty results set. (I have one row in the AspNetUsers table.)
var users = DbContext.Users.AsEnumerable();
I have not scaffolded Identity in this project. Here are a couple of related classes.
ApplicationUser.cs
public class ApplicationUser : IdentityUser
{
// Space to add custom fields
}
ApplicationDbContext.cs
public class ApplicationDbContext : IdentityDbContext
{
public DbSet<Area> Areas { get; set; }
public DbSet<Goal> Goals { get; set; }
public DbSet<Task> Tasks { get; set; }
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}
}
So basically anything that tries to access the Identity classes fails. What could possibly prevent me from reading the Users table? The only thing I can think of is that I messed something up with my ApplicationUser
class. Can anyone recommend what else I might try to isolate this? I'm blocked.
Besides, if you would ike to use custom user data, you also need to use the ApplicationUser
type as a generic argument for the context:
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>