title: Asp net core identity: how to get default ApplicationDbContext outside controller?
body: <p>I use Net Core 2.1 and I need to do some preparations on startup which require several direct Identity database queries. </p>
  
  <p>I tried:</p>
  
  <pre><code>using (var serviceScope = serviceProvider.GetRequiredService&lt;IServiceScopeFactory&gt;()
                      .CreateScope())
  {
      var identityDb = serviceProvider.GetService&lt;ApplicationDbContext&gt;();
  }
  </code></pre>
  
  <p>these lines produce exception: Cannot resolve scoped service 'Ecoc.Data.ApplicationDbContext' from root provider. 
  Is there a way to get database context in arbitrary place of code? </p>