Asp.Net Core 5.0 SignalR with SQL Dependency

Kmcnet 696 Reputation points
2022-03-01T20:28:42.117+00:00

Hello everyone and thanks for the help in advance. I am porting older Asp.Net 4.5 application to .Net Core 5. A few of these applications have SignalR with SQL Dependency notification which I ahve been unsuccessful in porting to the new platform. IN Google searching, it seems many have run into this same problem, but no one has found a solution. Is this simply not supported in .Net Core? Any help would be appreciated.

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,177 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,263 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Zhi Lv - MSFT 32,016 Reputation points Microsoft Vendor
    2022-03-02T09:10:17.837+00:00

    Hi @Kmcnet ,

    I found this sample: database-change-notification-using-signal (using asp.net core 2.2) from Github, after upgrade the asp.net core version to Asp.net 5, the SQL Dependency notification still works well.

    The part of modified code:

    EmployeeRepository.cs:

    179166-image.png

    The Startup:

    179157-image.png

    The .csproj file:

    <Project Sdk="Microsoft.NET.Sdk.Web">  
      
      <PropertyGroup>  
        <TargetFramework>net5.0</TargetFramework>    
      </PropertyGroup>  
      
      <ItemGroup>  
        <PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="5.0.11" />  
        <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.11" />  
        <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="5.0.11" />  
        <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.11" />  
        <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.11" />  
        <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.2" />  
      </ItemGroup>  
      
      <ItemGroup>  
        <Folder Include="Migrations\" />  
      </ItemGroup>  
      
    </Project>  
    

    The result is like this:

    179232-2.gif

    More detail sample code, you can check the above Github link and the attachment.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,
    Dillion

    0 comments No comments

  2. Kmcnet 696 Reputation points
    2022-03-08T03:02:51.93+00:00

    Thanks for the response. I'm working through the example but my biggest question is this, at least seems, to sidestep the use of SignalR hubs like most of the examples. So I am confused on why this works.