title: IAuthorizationHandler as singleton gives me threading related issue
body: <p>In <code>startup.cs</code>, I have the below code line:</p>
  
  <pre><code>services.AddSingleton(IAuthorizationHandler, RoleBasedHandler&gt;().cs 
  </code></pre>
  
  <p>It gives an error in database operation and the error message says: </p>
  
  <blockquote>
    <p>A second operation started on this context before the previous
    operation completed. This is usually caused by different threads using
    the same instance of DbContext.</p>
  </blockquote>
  
  <p>When I changed that code line in <code>startup.cs</code>to:</p>
  
  <pre><code>services.Transient(IAuthorizationHandler, RoleBasedHandler&gt;() 
  </code></pre>
  
  <p>the error has gone. My understanding is that singleton version <code>RoleBasedHandler</code> creates only one <code>DbContext</code> object and it tries to reuse it in threads executing at the same time. <code>DbContext</code> object cannot work with more than one thread, therefore it breaks.</p>
  
  <p>What is a best practice recommendation for my case?</p>