0

According to Scaleout with SQL Server you can use SignalR.SqlServer to keep SignalR synced on a load balancing setup. I have an existing MVC 5 website with its own database created using Entity Code First. The article seems to use a dedicated database with service broker enabled and says not to modify the database.

So do I need to have a separate database for this? I know Entity can be picky if the database schema doesn't match and I worry that if I try to use the SignalR Sql Server package with the existing database that the tables it creates will cause a context changed error.

Also can someone provide me with more information about using the Microsoft.AspNet.SignalR.SqlServer package. The article I linked doesn't give a ton of detail and I don't know if I need to change anything in my hub and groups or if it is all handled automatically.

Garrett Fogerlie
  • 4,450
  • 3
  • 37
  • 56

1 Answers1

1

You should be able to, though you'd likely want to separate your entity framework definitions from signalR. You can either put SignalR in a separate database, or give the two a separate schema.

In terms of configuration, you'll need to make an addition to the Startup class of your web project:

public class Startup 
{   
    public void Configuration(IAppBuilder app) 
    {           
        var sqlConnectionString = "connection string here";
        GlobalHost.DependencyResolver.UseSqlServer(sqlConnectionString); 
        this.ConfigureAuth(app);
        app.MapSignalR();
    }
}
John Christensen
  • 5,020
  • 1
  • 28
  • 26
  • This assumes that your running application has permission to modify the schema (or even add schema) to the database, which in the real world is rarely acceptable – caesay Jun 01 '18 at 13:24