I am trying to build a simple login system from the ground up, using ASP.NET MVC v5, Entity Framework v7, and Identity v3.
All I want is for the user to create an account, and for that account to be saved in a database. This is the Register POST action:
[HttpPost]
public async Task<IActionResult> Register (RegisterViewModel model)
{
try
{
var userStore = new UserStore<ApplicationUser>(db);
var userManager = new UserManager<ApplicationUser>(userStore);
var user = new ApplicationUser { UserName = model.Email };
IdentityResult result = await userManager.CreateAsync(user, model.Password);
return RedirectToAction(nameof(HomeController.Index), "Home");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return View();
}
}
I'm getting the error here for UserManager
:
Error CS7036 There is no argument given that corresponds to the required formal parameter 'optionsAccessor' of 'UserManager.UserManager(IUserStore, IOptions, IPasswordHasher, IEnumerable>, IEnumerable>, ILookupNormalizer, IdentityErrorDescriber, IServiceProvider, ILogger>, IHttpContextAccessor)'
What does this mean/how do I approach this?
I'm also wondering about this because when you create a scaffolded MVC app, in the generated AccountController, UserManager never takes any arguments (even though the error message says that they are "required" formal parameters), yet the app is able to register users.