title: How to create a child scope from the parent with default dependency injection in .NET Core?
body: <p>I am building a console .NET Core application. It periodically runs a method that does some work. How do I make ServiceProvider behave in the same way it behaves in ASP.NET Core apps. I want it to resolve scoped services when the method begins it's execution and dispose the resolved services at the end of the method.</p>
  
  <pre><code>// pseudocode
  
  globalProvider.AddScoped&lt;ExampleService&gt;();
  
  // ...
  
  using (var scopedProvider = globalProvider.CreateChildScope())
  {
      var exampleService = scopedProvider.Resolve&lt;ExampleService&gt;();
  }
  </code></pre>