title: Asp.Net Core Cannot access a disposed context instance
body: <p>I'm trying to implement SignalR in order to consume data from a angular frontend application.</p>
  <p>I've checked all the results on google that I can find, but I still can't solve my issue.</p>
  <p>The error I'm getting is:</p>
  <blockquote>
  <p>Cannot access a disposed context instance. A common cause of this
  error is disposing a context instance that was resolved from
  dependency injection and then later trying to use the same context
  instance elsewhere in your application. This may occur if you are
  calling 'Dispose' on the context instance, or wrapping it in a using
  statement. If you are using dependency injection, you should let the
  dependency injection container take care of disposing context
  instances. Object name: 'AdminContext'</p>
  </blockquote>
  <p><strong>Controller</strong></p>
  <pre class="lang-cs prettyprint-override"><code>[Route(&quot;api/[controller]&quot;)]
  [ApiController]
  public class ChartController : ControllerBase
  {
      private IHubContext&lt;ChartHub&gt; _hub;
      private readonly ILiveMonitoringService _service;
  
      public ChartController(IHubContext&lt;ChartHub&gt; hub, ILiveMonitoringService service)
      {
          _hub = hub;
          _service = service;
  
      }
      public IActionResult Get()
      {
          var timerManager = new TimerManager(async () =&gt; await _hub.Clients.All.SendAsync(&quot;transferchartdata&quot;, await _service.GetAllAsync()));
          return Ok(new { Message = &quot;Request Completed&quot; });
      }
  }
  </code></pre>
  <p><strong>Service</strong></p>
  <pre class="lang-cs prettyprint-override"><code>public Task&lt;List&lt;LiveMonitoring&gt;&gt; GetAllAsync()
  {
      return _repository.GetAll().Take(100).ToListAsync();
  }
  </code></pre>
  <p><strong>Repository</strong></p>
  <pre class="lang-cs prettyprint-override"><code>public IQueryable&lt;TEntity&gt; GetAll()
  {
      try
      {
          return _adminContext.Set&lt;TEntity&gt;();
      }
      catch (Exception ex)
      {
          throw new Exception(&quot;Couldn't retrieve entities&quot;);
      }
  }
  </code></pre>
  <p>What could be the problem?</p>