title: How to add new AspNetCore.IdentityUser to EntityFrameworkCore.DbContext?
body: <p>I'm learning to use AspNetCore.Identity and EntityFrameworkCore, and figured I could for example have an enum of system roles and have EF populate with them on creation, like this:</p>
  <pre><code>protected override void OnModelCreating(ModelBuilder modelBuilder)
  {
      foreach (var e in EnumToStrArray&lt;SystemRoles&gt;())
      {
          var roleId = Guid.NewGuid().ToString();
          modelBuilder
              .Entity&lt;AspNetRole&gt;() // AspNetRole inherits from IdentityRole
              .HasData(new AspNetRole(e)
              {
                  Id = roleId,
                  NormalizedName = e.ToUpper()
              });
      }
  }
  </code></pre>
  <p>and so I figured I might as well create a default admin user because I'd like to enable him to register new users for now so not everyone can just come and create an account. Don't judge me.</p>
  <p>Well, adding new user is a copy-pase of adding new role, like this:</p>
  <pre><code>var adminUserId = Guid.NewGuid().ToString();
  modelBuilder
      .Entity&lt;AspNetUser&gt;() // again, AspNetUser : IdentityUser
      .HasData(new AspNetUser(&quot;Admin&quot;)
      {
          Id = adminUserId,
          Email = &quot;admin@mt.com&quot;,
          NormalizedEmail = &quot;ADMIN@MT.COM&quot;,
          |BOOKMARK|
      });
  </code></pre>
  <p>well, almost...</p>
  <p>My admin user doesn't have a password, so I can't login with him, and I can't set a password that easy because <code>IdentityUser</code> doesn't have a field like that. But it does have <code>PasswordHash</code>, so, I've created a new user through my web app, a hash was created, I got to my database, copied the hash and pasted it to my code, like this at in the <code>|BOOKMARK|</code> line</p>
  <pre><code>PasswordHash = &quot;AQAAAAEAACcQAAAAEIs31O9T9imY2du6anCZjshZuowUapaWJeNpl2B20H9MfM7qDE9kCHdOQ9JzDnxtqw==&quot;
  </code></pre>
  <p>Surprise, surprise, it didn't work and so I'm here.</p>
  <p>Is it possible to add a user with password to <code>IdentityDbContext</code> child class on <code>OnModelCreating</code>?</p>