title: Getting a task was canceled error when trying to seed roles in .NET Core 3.0
body: <p>In my .NET Core 3.0 application, I'm trying to seed new roles and users into the database the first time the application executes and connects to the database.</p>
  
  <p>So I've written this simple class:</p>
  
  <pre><code>public static class UserAndRoleDataInitializer
  {
      public static void SeedData(UserManager&lt;AppUser&gt; userManager, RoleManager&lt;IdentityRole&lt;Guid&gt;&gt; roleManager)
      {
          SeedRoles(roleManager);
          SeedUsers(userManager);
      }
  
      private static async void SeedRoles(RoleManager&lt;IdentityRole&lt;Guid&gt;&gt; roleManager)
      {           
          var exists = await roleManager.RoleExistsAsync("administrator");
          if (!exists)
          {               
              await roleManager.CreateAsync(new IdentityRole&lt;Guid&gt;("administrator"));
          }
  
          exists = await roleManager.RoleExistsAsync("editor");
          if (!exists)
          {
              await roleManager.CreateAsync(new IdentityRole&lt;Guid&gt;("editor"));
          }
      }
  
      ...
  }
  </code></pre>
  
  <p>which is invoked from <code>Program.cs</code>: </p>
  
  <pre><code>var userManager = serviceProvider.GetRequiredService&lt;UserManager&lt;AppUser&gt;&gt;();
  var roleManager = serviceProvider.GetRequiredService&lt;RoleManager&lt;IdentityRole&lt;Guid&gt;&gt;&gt;();
  UserAndRoleDataInitializer.SeedData(userManager, roleManager);
  </code></pre>
  
  <p>Each time <code>SeedData</code> is executed I get the following error:</p>
  
  <blockquote>
    <p><strong>System.Threading.Tasks.TaskCanceledException</strong>: 'A task was canceled.'</p>
  </blockquote>
  
  <p>on the first line of <code>SeedRoles</code>: <strong><code>var exists = await roleManager.RoleExistsAsync("administrator");</code></strong></p>
  
  <p>I've researched the web trying to find some answers but couldn't find anything similar to my use case. Any help would be greatly appreciated.  </p>