title: How do I seed user roles in Identity ASP.NET Core 2.1 (Identity Scaffolded)
body: <p>How do I seed a "admin" user role when identity is scaffolded?</p>
  
  <p>I would like to find my power-user account by email and seed the admin role.
  Most examples I find use <code>Startup.cs</code>, but you are supposed to use <code>IdentityHostingStartup.cs</code> to register identity related services.</p>
  
  <p>So where/how do I inject the <code>RoleManager</code> and <code>UserManager</code> in <code>IdentityHostingStartup</code>? (I assume this is what I need, please let me know if there is a better way)</p>
  
  <pre><code>  public class IdentityHostingStartup : IHostingStartup
    {
          public void Configure(IWebHostBuilder builder)
          {
              builder.ConfigureServices((context, services) =&gt; {
                  services.AddDbContext&lt;MyWebContext&gt;(options =&gt;
                      options.UseSqlServer(
                          context.Configuration.GetConnectionString("MyWebContextConnection")));
  
                  services.AddIdentity&lt;MyWebUser, MyWebRole&gt;()
                      .AddRoles&lt;MyWebRole&gt;()
                      .AddRoleManager&lt;RoleManager&lt;MyWebRole&gt;&gt;()
                      .AddDefaultUI()
                      .AddEntityFrameworkStores&lt;MyWebContext&gt;();
  
                  services.Configure&lt;IdentityOptions&gt;(options =&gt; {
                      options.Password.RequireNonAlphanumeric = false;
                      });
              });
          }
    }
  </code></pre>