title: ASP.NET Core initialize singleton after configuring DI
body: <p>So let's say I have a singleton class instance that I register in the DI like this:</p>
  
  <pre><code>services.AddSingleton&lt;IFoo, Foo&gt;();
  </code></pre>
  
  <p>And let's say the <code>Foo</code> class has a number of other dependencies (mostly repository classes that allow it to load data). </p>
  
  <p>With my current understanding, the Foo instance is not created until it's first used (asked). Is there a way to initialize this class other than the constructor? Like right after <code>ConfigureServices()</code> completes? Or should the initialization code (loading data from db) be done in Foo's constructor?</p>
  
  <p>(It would be nice if this class could load its data before the first use to speed up first time access)</p>