10

Is it possible to leverage System.Data.SqlClient.SqlDependency from within a .NET Core v1.1 application? It appears that most of the other classes and methods within System.Data.SqlClient are available except SqlDependency.

Essentially, I'm trying to subscribe to SQL notifications when table data changes to then update the client's UI, so I'm open to other ways to achieve this if SqlDependency is not available from .NET Core.

Thanks in advance! Here's my complete project.json file:

{
 "dependencies": {
 "Microsoft.NETCore.App": {
 "version": "1.1.0",
 "type": "platform"
 },
 "Microsoft.AspNetCore.Authentication": "1.0.0",
 "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
 "System.IdentityModel.Tokens.Jwt": "5.0.0",
 "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.0.0",
 "Microsoft.AspNetCore.Authentication.Google": "1.0.0",
 "Microsoft.AspNetCore.Authentication.JwtBearer": "1.0.0",
 "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
 "Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
 "Microsoft.AspNetCore.StaticFiles": "1.1.0",
 "Microsoft.EntityFrameworkCore": "1.1.0",
 "Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
 "Microsoft.EntityFrameworkCore.SqlServer.Design": "1.1.0",
 "Microsoft.Extensions.Configuration.Binder": "1.1.0",
 "Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
 "Microsoft.Extensions.Configuration.Json": "1.1.0",
 "Microsoft.Extensions.Logging.Console": "1.1.0",
 "Microsoft.AspNetCore.Diagnostics": "1.1.0",
 "Microsoft.AspNetCore.Identity": "1.1.0",
 "Microsoft.AspNetCore.Mvc": "1.1.0",
 "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
 "Microsoft.AspNetCore.Rewrite": "1.0.0",
 "Microsoft.AspNetCore.ResponseCompression": "1.0.0",
 "Microsoft.AspNetCore.SignalR.Server": "0.2.0-*",
 "Microsoft.AspNetCore.WebSockets": "0.2.0-*"
 },
 "tools": {
 "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
 "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
 "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final"
 },
 "frameworks": {
 "netstandard1.1": {
 "imports": [
 "dotnet5.6",
 "portable-net45+win8",
 "net461",
 "dnxcore50"
 ]
 }
 },
 "buildOptions": {
 "emitEntryPoint": true,
 "preserveCompilationContext": true
 },
 "runtimeOptions": {
 "configProperties": {
 "System.GC.Server": true
 }
 },
 "publishOptions": {
 "include": [
 "Views",
 "wwwroot",
 "appsettings.json",
 "appsettings.dev.json",
 "web.config"
 ]
 },
 "scripts": {
 "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
 }
}
Ralph Willgoss
12.3k4 gold badges67 silver badges69 bronze badges
asked Jan 15, 2017 at 2:01
4
  • 1
    According to packagesearch.azurewebsites.net?q=SqlDependency it's not there. There is a chance though that it may come with .NET Standard 2.0, as over 5000 new APIs will be added to make migrations easier from .NET Framework to .NET Core Commented Jan 15, 2017 at 10:34
  • @Tseng, I am looking for this too. Any update 4 months later? Or should I switch to owin and full framework to build SignalR server with SqlDependency? Commented May 10, 2017 at 9:11
  • Asked about the same thing, but it doesn't look like there will be support for this in .net core twitter.com/DamianEdwards/status/866464629819555840 Commented May 23, 2017 at 0:16
  • Note: If you're planning on using SqlDependency with SQL Azure it won't work unless you have your own managed instance stackoverflow.com/questions/37640879 Commented Jun 26, 2019 at 22:08

2 Answers 2

7

There's a .Net Core based open source solution available on GitHub : https://github.com/dyatchenko/ServiceBrokerListener

I'm not sure about the performance however, because it seems that the multiple client-app listening for changes are creating dedicated queues. So maybe it doesn't scale as good as the original SqlDependency.

answered Jun 2, 2017 at 7:28
5

According to this https://github.com/dotnet/corefx/issues/8188 it will be there in .NET Core 2.1, but I haven't seen anything about whether the usage differs from .NET Framework. I hope it doesn't.

Miriam Farber
19.7k15 gold badges65 silver badges78 bronze badges
answered Aug 13, 2017 at 22:41
2
  • 1
    Can someone confirm (link to docs?) that this did in fact ship in 2.1? Commented Jan 7, 2019 at 16:20
  • 1
    This link lists 2.1, 2.2 learn.microsoft.com/en-us/dotnet/api/… Commented Jan 22, 2019 at 21:23

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.