title: InvalidOperationException when registering a new user with ASP .NET Core Identity and EntityFrameworkCore
body: <p>I'm following the <a href="https://docs.asp.net/en/latest/security/authentication/identity.html" rel="nofollow noreferrer">documentation for using Identity</a> and am trying register a new user (executing the register action), but it fails with the following error:</p>
  
  <blockquote>
    <p>InvalidOperationException: Cannot create a DbSet for 'ApplicationUser'
    because this type is not included in the model for the context.</p>
  </blockquote>
  
  <p>Startup:</p>
  
  <pre><code>services.AddIdentity&lt;ApplicationUser, IdentityRole&gt;(options =&gt;
  {
      //password options
      options.Password.RequireDigit = false;
      // ...
  })
  </code></pre>
  
  <p>I am using a standard ApplicationUser:</p>
  
  <pre><code>public class ApplicationUser : IdentityUser
  {
  }
  </code></pre>
  
  <p>Register action in AccountController:</p>
  
  <pre><code>public async Task&lt;IActionResult&gt; Register(RegisterViewModel viewModel)
  {
      if (ModelState.IsValid)
      {
          var user = new ApplicationUser { UserName = viewModel.UserName, Email = viewModel.Email };
          var result = await _userManager.CreateAsync(user, viewModel.Password); //&lt;-- Exception happens here
          if (result.Succeeded)
          {
              await _signInManager.SignInAsync(user, isPersistent: false);
              _logger.LogInformation(3, "User created a new account with password.");
              return RedirectToAction(nameof(HomeController.Index), "Home");
          }
  
          string errorData = "";
          foreach (var error in result.Errors)
          {
              errorData += error.Description + '\n';
          }
          StoreErrorMessage("Failed to create the user!", errorData);
      }
  
      return View(viewModel);
  }
  </code></pre>
  
  <p>I already tried the following:</p>
  
  <ul>
  <li>Adding <code>DbSet&lt;ApplicationUser&gt;</code> to <code>AplicationContext</code></li>
  <li>I did create and apply a new migration via <code>dotnet ef</code></li>
  </ul>