title: Asp.Net Core Identity Create User
body: <p>I have trouble creating a user. The process runs correctly, reads data to user, redirects to Home / Index, but there is no new user in the database.
  I have the same code in DbSeeder and the users are created correctly there.</p>
  <pre class="lang-cs prettyprint-override"><code>[HttpPost]
          public async Task&lt;IActionResult&gt; Create(WorkerVM model)
          {
              if (ModelState.IsValid)
              {
                  var user = await _userManager.FindByNameAsync(model.Username);
  
                  if (user == null)
                  {
                      user = new User()
                      {
                          FirstName = model.FirstName,
                          LastName = model.LastName,
                          Email = model.Username,
                          UserName = model.Username
                      };
  
                      var result = await _userManager.CreateAsync(user, model.Password);
                      if (result.Succeeded)
                      {
                          await _userManager.AddToRoleAsync(user, &quot;Worker&quot;);
                      }
                      return RedirectToAction(&quot;Index&quot;, &quot;Home&quot;);
                  }
              }
              
              ModelState.AddModelError(&quot;&quot;, &quot;Registration Failed&quot;);
  
              return View();
          }
  </code></pre>