title: Create one user and role in OnModelCreating for EF core
body: <p>I am working on an asp.net-core 2.0 project.</p>
  
  <p>This project contains a database with Entity Framework Core. I am working on Code First mode with migrations.</p>
  
  <p>What i want to do is to create some default datas in my database on structure creation.</p>
  
  <p>I need to create an User.</p>
  
  <p>I have looked in OnModelCreating function in my IdentityDbContext class but i have no way to access to userManager object.</p>
  
  <p>So i do not know how to do.... Thanks</p>
  
  <p>Here is my code:</p>
  
  <pre><code>    public class MyContext : IdentityDbContext&lt;Utilisateurs&gt;
      {
          public static string ConnectionString;
  
          public MyContext()
          {
  
          }
  
          public MyContext(DbContextOptions&lt;pluginwebContext&gt; options) : base(options)
          {
  
          }
  
          protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
          {
              optionsBuilder.UseSqlServer(MyContext.ConnectionString);
          }
  
          protected override void OnModelCreating(ModelBuilder modelBuilder)
          {
              base.OnModelCreating(modelBuilder);
              var user = new MyUserClass { UserName = "test" };
  
              // Error There
              var result = await _userManager.CreateAsync(user, "1234");
          }
  
          public DbSet&lt;MyTable1&gt; table1 { get; set; }
          ...
      }
  </code></pre>