title: .NET Core Identity UserManager always returning null for user
body: <p>I am currently trying to hook up Identity's <code>UserManager</code> class to a simple application. When trying to do so, <code>.FindByEmailAsync</code> as well as any other method to try to find users is always returning me a null user. The <code>UserManager</code> itself is not null but it seems unable to find any of my users properly. Everything in my app uses the same database and I've verified the user exists in the db.</p>
  
  <pre><code>[Route("api/[controller]")]
  [ApiController]
  public class UsersController : ControllerBase
  {
      private SignInManager&lt;ApplicationUser&gt; _signInManager;
      private UserManager&lt;ApplicationUser&gt; _userManager;
  
      public UsersController(UserManager&lt;ApplicationUser&gt; userManager, SignInManager&lt;ApplicationUser&gt; signInManager)
      {
          _userManager = userManager;
          _signInManager = signInManager;
      }
  
      public async Task&lt;ActionResult&lt;ApplicationUser&gt;&gt; Get()
      {
          //this returns null
          var user = await _userManager.FindByEmailAsync("admin@admin.com");
  
          //this works
          using (var db = new ApplicationDbContext(GetDbOptions()))
          {
              return db.Users.Single(x =&gt; x.Email == "admin@admin.com")
          }
      }
  
  }
  </code></pre>
  
  <p>My <code>Startup.cs</code> class looks as follows:</p>
  
  <pre><code>services.AddDbContext&lt;ApplicationDbContext&gt;(options =&gt;
  
  options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
  
  services.AddIdentityCore&lt;ApplicationUser&gt;()
      .AddEntityFrameworkStores&lt;ApplicationDbContext&gt;()
      .AddDefaultTokenProviders();
      //.AddSignInManager&lt;SignInManager&lt;ApplicationUser&gt;&gt;() tried adding these with no success- same behavior
      //.AddUserManager&lt;UserManager&lt;ApplicationUser&gt;&gt;();
  </code></pre>
  
  <p>The user is being seeded in the db as follows:</p>
  
  <pre><code>    private static void SeedIdentityUsers(IServiceScope serviceScope)
      {
          var context = serviceScope.ServiceProvider.GetRequiredService&lt;ApplicationDbContext&gt;();
          var PasswordHash = new PasswordHasher&lt;ApplicationUser&gt;();
  
          if (!context.Users.Any(u =&gt; u.UserName == "admin@admin.com"))
          {
              var user = new ApplicationUser
              {
                  UserName = "admin@admin.com",
                  Email = "admin@admin.com",
              };
  
              user.PasswordHash = PasswordHash.HashPassword(user, "somepassword");
              context.Users.Add(user);
              context.SaveChanges();
          }
      }
  </code></pre>