Back in .NET Framework, the
System.Data.SqlClient
namespace was included in the
System.Data
assembly. But for .NET Core and .NET 5/6/7/etc. that is no longer the case. For those platforms, or for class libraries targeting .NET Standard, you need to reference a NuGet package to use this namespace.
Since Microsoft only seems to be happy when developers are confused, there are now
two ways to reference the
SqlClient
namespace in .NET:
They're largely similar, but the
Microsoft.Data.SqlClient
package is newer, and is recommended for any new projects:
Introducing the new Microsoft.Data.SqlClient - .NET Blog[
^]