title: Adding role to Identity programmatically
body: <p>Before every thing I should say: &quot;<strong>Why things that used to be easy have become so difficult now!!!!</strong>&quot;</p>
  <p>I create a <code>Class Library</code> project for my EF data context. I want to use <code>Identity</code> too. So I create context class like this:</p>
  <pre><code>public class Context : IdentityDbContext
  {
      protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
      {
          optionsBuilder.UseSqlServer(&quot;Server=.;Database=MyDB1;Trusted_Connection=True;&quot;);
          base.OnConfiguring(optionsBuilder);
      }
  }
  </code></pre>
  <p>and I add migration and update database. So I want to write some code to add a role to role table and use : <code>RoleManager&lt;IdentityRole&gt;</code> :</p>
  <pre><code>private readonly RoleManager&lt;IdentityRole&gt; _rolesManager;
  
  public RoleRepository()
  {
      _rolesManager = new RoleManager&lt;IdentityRole&gt;();
  }
  
  public async Task AddRole(string roleName)
  {
      var role = new IdentityRole();
      role.Name = roleName;
      await _roleManager.CreateAsync(role);
  }
  </code></pre>
  <p>the problem is I can't instantiate from <code>RoleManager&lt;IdentityRole&gt;</code> and I get this error:</p>
  <blockquote>
  <p>There is no argument given that corresponds to the required formal parameter 'store' of 'RoleManager.RoleManager(IRoleStore, IEnumerable&lt;IRoleValidator&gt;, ILookupNormalizer, IdentityErrorDescriber, ILogger&lt;RoleManager&gt;)'</p>
  </blockquote>
  <p>How can I add this parmaters when instantiate from <code>RoleManager&lt;IdentityRole&gt;</code>?</p>
  <p>How can I add role To Role table in a class library project?</p>
  <p>Thanks</p>