Microsoft's new SQL client is here!
A few months back, Microsoft released a brand new SQL client library called Microsoft.Data.SqlClient on NuGet. Wait…didn't we already have a stable SQL client library shipped as a part of .NET Framework? Why reinvent the wheel?
Let's see why, which one you should choose, and how this affects our NServiceBus packages.
Have you noticed that database servers are getting more frequent updates? To make use of new features in the server, you need an updated client library. This is especially true in the cloud with services such as Azure SQL Database that tend to update very often.
Unfortunately, the System.Data.SqlClient library is also shipped as part of the .NET Framework and can only be updated when a new version of the .NET Framework is released. Releasing new versions of the .NET Framework is a big task and is limited by the Microsoft support and backward compatibility guarantees. New versions of the .NET Framework are not released as often as the client library needs to be updated.
To resolve this situation Microsoft released a new client library called Microsoft.Data.SqlClient. This client library is shipped outside of the .NET Framework, only as a NuGet package. The NuGet package can be released much more frequently than the .NET Framework, allowing clients to keep up to date with the latest changes on the server.
In most cases, the Microsoft.Data.SqlClient will be the one you should use for any project moving forward, and you will probably need to convert existing projects to use it over time as well.
As there is feature parity between the old and the new SQL clients at the time of writing this post, it should be fairly easy to migrate to the new SQL client.
For NServiceBus users, we have a few packages that are affected:
- For the SQL Server Transport, we now have two separate packages:
- NServiceBus.SqlServer will continue to use the System.Data.SqlClient.
- NServiceBus.Transport.SqlServer is a new package that contains the same code, but uses the new Microsoft.Data.SqlClient package. The first release of this package is version 6, matching the current version of the NService.SqlServer package, and we will continue to release both packages in lockstep.
- For SQL Persistence, we've added support for the new SQL client in NServiceBus.Persistence.Sql version 5. Because SQL Persistence uses a connection builder approach to creating the
SqlConnectionobject, you can use your choice of SQL client with the same SQL Persistence package.
As indicated in our support policy, the older packages that depend on the old SQL client will remain supported until Feb 2021.
If you are using an older version of libraries such as EntityFramework, Dapper, or other third-party libraries relying on SQL client, the best approach is to upgrade them all at once, as the chances are high that the newer version of those libraries won't support the old SQL client.
There is a new SQL client library from Microsoft that will receive faster updates. We have made it available in our SQL Transport and Persistence libraries so you can start using it in your solutions now.
For more infomation, please see:
- NServiceBus SQL Persistence upgrade guide
- NServiceBus SQL Transport upgrade guide
- Introduction and the roadmap of the new SQL Client
About the Authors: Hadi Eskandari and Mike Minutillo are both developers at Particular Software. When not at his computer, Hadi is on the lookout to take pictures of the amazing landscapes in Australia and beyond. Mike can be found playing tabletop games with people all around the world using online collaboration tools. As parents, they are both excited to see SqlClient growing up and striking out on its own.