title: SignalR Hubs Clients are null when firing event
body: <p>I've written a generic hubs which I'm having some issues with so to debug it I've decided to make a simple connection count like so:</p>
  
  <pre><code>public class CRUDServiceHubBase&lt;TDTO&gt; : Hub, ICRUDServiceHubBase&lt;TDTO&gt;
  {
      public const string CreateEventName = "EntityCreated";
      public const string UpdateEventName = "EntityUpdated";
      public const string DeleteEventName = "EntityDeleted";
  
      protected int _connectionCount = 0;
  
      public Task Create(TDTO entityDTO)
      {
          return Clients.All.InvokeAsync(CreateEventName, entityDTO);
      }
  
      public Task Update(TDTO entityDTO)
      {
          return Clients.All.InvokeAsync(UpdateEventName, entityDTO);
      }
  
      public Task Delete(object[] id)
      {
          return Clients.All.InvokeAsync(DeleteEventName, id);
      }
  
      public override Task OnConnectedAsync()
      {
          this._connectionCount++;
          return base.OnConnectedAsync();
      }
  
      public override Task OnDisconnectedAsync(Exception exception)
      {
          this._connectionCount--;
          return base.OnDisconnectedAsync(exception);
      }
  }
  
  public class MessagesHub : CRUDServiceHubBase&lt;MessageDTO&gt;
  {
      public MessagesHub() : base()
      {
      }
  }
  </code></pre>
  
  <p>I'm registering this class like so:</p>
  
  <pre><code>services.AddTransient&lt;ICRUDServiceHubBase&lt;MessageDTO&gt;, MessagesHub&gt;();
  </code></pre>
  
  <p>I have a service who is using this, which I'm using it's implementation factory to subscribing to it's events: </p>
  
  <pre><code>services.AddTransient&lt;IMessageDTOService&gt;( (c) =&gt; {
  
      var context = c.GetRequiredService&lt;DbContext&gt;();
      var adapter = c.GetRequiredService&lt;IAdaptable&lt;Message, IMessageDTO, MessageDTO&gt;&gt;();
      var validator = c.GetRequiredService&lt;IValidator&lt;Message&gt;&gt;();
      var entityMetadataService = c.GetRequiredService&lt;IEntityMetadataService&lt;Message&gt;&gt;();
  
      var service = new MessageDTOService(context, adapter, validator, entityMetadataService);
      var hub = c.GetService&lt;ICRUDServiceHubBase&lt;MessageDTO&gt;&gt;();
      this.RegisterHubsCreate(service, hub);
  
      return service;
  });
  </code></pre>
  
  <p>When I go to fire the event I get a null reference:</p>
  
  <blockquote>
    <p>Microsoft.AspNetCore.SignalR.Hub.Clients.get returned null.</p>
  </blockquote>
  
  <p>My best guess is that because the service is a dependency for the controller, It's created before signalR can initialize It's clients?</p>
  
  <p>Does anyone have a suggestion on how I can register my events, and have a client populated?</p>