title: Service Fabric Stateful Service with Asp.net Core Dependency Injection
body: <p>I use Asp.net core DI correctly in my Stateless service since is basically a normal WebApi application with controllers.</p>
  
  <p>I can't figure out how to use Dependency Injection in Stateful Services.
  This is the default constructor for the Stateful service:</p>
  
  <pre><code> public MyService(StatefulServiceContext context): base(context)
          {            
          }
  </code></pre>
  
  <p>And is called in Program.cs by</p>
  
  <pre><code>ServiceRuntime.RegisterServiceAsync("MyStatefulType",context =&gt; new MyService(context)).GetAwaiter().GetResult();
  </code></pre>
  
  <p>I would like to use something like this in the Stateful service:</p>
  
  <pre><code>  private readonly IHelpers _storageHelpers;
          public MyService(IHelpers storageHelpers)
          {
              _storageHelpers = storageHelpers;
          }
  </code></pre>
  
  <p>I already registered it in the Configuration section of the Stateful service, but if I try to use the code above I have the error:</p>
  
  <p><strong>StatefulService does not contain a constructor that takes 0 arguments</strong></p>
  
  <p>How to make it work?</p>