Asked by
+FloatingFatMan,
By incendy,
Tagged with:
We rely on ads to keep creating quality content for you to enjoy for free.
Please support our site by disabling your ad blocker.
Continue without supporting us
If the prompt is still appearing, please disable any tools or services you are using that block internet ads (e.g. DNS Servers, tracking protection or privacy extensions).
Question
+FloatingFatMan Subscriber¹
Is anyone here experienced with SQLDependency, SignalR and Entity Framework's code first model?
I'm currently developing an MVC website with a SQL Server backend and am using EF6 for the the ORM. I need to implement push notifications so that users are notified of certain events.
Now, I have all this working just fine. Users are getting their notifications and everything is behaving as it should except when, in the development environment only, a change is made to one of the database tables.
In the normal course of events with Code First, a change to an entity causes the database to be dropped and re-created, and the Seed method reran to populate with my test data, however since implementing push notifications this is no longer working and I get the following error in my Application_Start method of Global.asax.cs.
The error happens when it hits the following line (con is my connection string).
SqlDependency.Start(con);
Obviously, this is wigging out because the database has been dropped and will be created so there are no logins for it yet (using Windows Authentication), but why hasn't the damned thing created the new one by now? The Database.SetInitializer is right at the top of the method and surely it should have gotten it done by the time it tries to start the SqlDependency? I feel that I'm missing something here...
This is the first time I've tried using SignalR, so do I have to run the SqlDependency.Start() method in Application_Start, or can it be run from somewhere else that doesn't fire until AFTER the new DB is created? It's rather a pain in the backside to have to disable this code whenever I have a table change (which is often right now), and 2 days of trawling through Goggle hasn't found a damned thing...
Anyone?
Link to comment
https://www.neowin.net/forum/topic/1313620-sqldependency-signalr-entity-framework-code-first/Share on other sites
0 answers to this question
Recommended Posts