• 0

SQLDependency, SignalR & Entity Framework Code First


Question

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.

 

  Quote

Additional information: Cannot open database "xxxxx" requested by the login. The login failed.

Login failed for user 'xxxxxxxx'.

Expand  

 

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?

0 answers to this question

Recommended Posts

There have been no answers to this question yet

This topic is now closed to further replies.
  • Posts

    • Microsoft Defender XDR gets TITAN-powered Security Copilot recommendations by Paul Hill Guided Response, a Copilot-powered capability in Microsoft Defender XDR that guides analysts through step-by-step investigation and response flows, is getting a big upgrade with the introduction of TITAN recommendations. With TITAN, Microsoft wants to give security analysts real-time, threat-intel-driven recommendations so they can better prepare against attacks, before they even happen. TITAN is an adaptive threat intelligence graph that uses data from first and third-party telemetry and employs guilt-by-association techniques to warn analysts about unknown IP addresses that could pose a threat, due to their association with known malicious addresses. The primary benefit of TITAN is that security analysts get faster warnings about potential threats before they even have a chance to cause a problem. TITAN is an enhancement of Security Copilot Guided Response, rather than a replacement to it. With this extra tool, security analysts will be able to better keep up with evolving threats. Understanding TITAN's AI-powered threat intelligence The Redmond giant said that TITAN “represents a new wave of innovation” built upon its threat intelligence capabilities that introduces a real-time, adaptive threat intelligence graph. It takes telemetry from first and third-party sources such as Microsoft Defender for Threat Intelligence, Microsoft Defender for Experts, and customer feedback. The graph uses guilt-by-association techniques to mark unknown devices as threats, if they’re associated with known malicious entities. This gives security analysts a window of opportunity to take action and prevent harm. To identify potential threats, Microsoft uses a semi-supervised label propagation technique that assigns reputation scores to nodes based on the score of their neighbors. These reputation scores allow Microsoft’s unified security operation platform to implement containment and remediation actions via attack disruption. Practical impact and future outlook The new TITAN suggestion now appears within Guided Response as triage and containment recommendations. When a suspicious IP is detected, a Guided Response recommendation is automatically generated. These can help security analysts deal with various threats including IP addresses, IP ranges, and email senders. Microsoft said in early testing its TITAN recommendations have shown good results. TITAN boosted Guided Response triage accuracy by 8%, it reduced the time needed to investigate and respond to incidents, and its explainable recommendations gave analysts more confidence in the actions they take. As threats become more sophisticated, Microsoft’s TITAN will help to tackle threats before they even become an issue.
    • China wants the tech... if they were to invade, TSMC would destroy it's fabs and other critical information first. Plus, you can bet they have backups stored NOT in Taiwan.
    • Malware website host in China in 3….2…1
    • You totally missed what I was saying. Yes, the DHCP server software is largely unchanged since the Windows 2000 Server version. My statement was somewhat of a joke, but I was saying that *IF* the DHCP server was written using today's Windows 11 *ERA* design philosophy, it would be a mess. Yes, even on the latest version of Windows Server it still uses the old software, but that wasn't really the point.
    • Yeah no, they are nowhere at this same level. Whatsapp did survive a lot of time being "free" it is just meta/facebook wanting more money.
  • Recent Achievements

    • Enthusiast
      Motoman26 went up a rank
      Enthusiast
    • Mentor
      M. Murcek went up a rank
      Mentor
    • Explorer
      treker_ed went up a rank
      Explorer
    • Apprentice
      CHUNWEI went up a rank
      Apprentice
    • Veteran
      1337ish went up a rank
      Veteran
  • Popular Contributors

    1. 1
      +primortal
      673
    2. 2
      ATLien_0
      268
    3. 3
      +FloatingFatMan
      176
    4. 4
      Michael Scrip
      172
    5. 5
      Steven P.
      139
  • Tell a friend

    Love Neowin? Tell a friend!