title: How to use Roles in ASP.NET Core 2.1?
body: <p>I've created a test project using:</p>
  
  <pre><code>dotnet new razor --auth Individual --output Test
  </code></pre>
  
  <p>This creates a Startup.cs that contains:</p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services)
  {
      services.Configure&lt;CookiePolicyOptions&gt;(options =&gt;
      {
          // This lambda determines whether user consent for non-essential cookies is needed for a given request.
          options.CheckConsentNeeded = context =&gt; true;
          options.MinimumSameSitePolicy = SameSiteMode.None;
      });
  
      services.AddDbContext&lt;ApplicationDbContext&gt;(options =&gt;
          options.UseSqlite(
              Configuration.GetConnectionString("DefaultConnection")));
  
      services.AddDefaultIdentity&lt;IdentityUser&gt;()
          .AddEntityFrameworkStores&lt;ApplicationDbContext&gt;();
  
      services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
  }
  </code></pre>
  
  <p>I want to seed some users and roles. Both users and roles will use the same store (SQLite). I'm using a static class for seeding which it's called from <code>Program</code>.</p>
  
  <p>I can seed users, but not roles, since the above does not seem to inject a <code>RoleManager</code>.</p>
  
  <p>In ASP.NET Core 2.0 the following is used:</p>
  
  <pre><code>services.AddIdentity&lt;IdentityUser, IdentityRole&gt;()
  </code></pre>
  
  <p>I'm guessing <code>AddDefaultIdentity</code> is new in 2.1 but the problem is that it does not inject a <code>RoleMnager</code>, so what should I do?</p>