I\'m using AspNetCore.SignalR and I need advice on how to access my SQL Server database through my Hub. There are not a lot of resources out there about this. I know how to
I tested this code with .NET Core 3!
You have to add your DBContext to DI so you can get it from the Constructor of your Hub.
public class MyHub
{
private PlayerContext dbContext;
public MyHub(PlayerContext dbContext)
{
this.dbContext = dbContext;
}
public void YourMethod()
{
//call the dbContext here by Dot Notaition
}
}