Moving to a New SqlClient

DotNet developers, if you’re using the System.Data.SqlClient, stop. Move over to Microsoft.Data.SqlClient now.

It’s easy to do, well, it’s relatively easy to say that. The actual work isn’t that hard, but it can be a challenge to move assemblies. In any case,  you need to reference the new assembly in your code, and ensure you’ve downloaded the NuGet package.

Vicky Harp wrote a piece introducing this new provider, and you can find plenty of posts around the Internet (and videos) that explain how to change and why.

Essentially, when you have the new assembly, you change this line:

Using System.Data.SqlClient;

to this:

Microsoft.Data.SqlClient;

If you haven’t fully qualified the assembly at the top and did it in code, you can search and replace.

The big reason for the change is to allow the ADO.NET provider to release quicker and keep up with changes in technology. When the SqlClient has shipped with dotNet or dotNet Core, it upgraded rather rarely, and the pace of change was disconnected from features being added to SQL Server. Now Vicky’s team has responsibility here and is upgrading this at a more rapid pace.

Let your friends know, and if you see System.Data.SqlClient in a code review, consider trying to refactor that out.

About way0utwest

Editor, SQLServerCentral
This entry was posted in Blog and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.