Problem with NuGet Microsoft Data SqlClient library

Tom Spence 25 Reputation points
2025-10-09T16:45:12.52+00:00

Microsoft Data SqlClient is referenced in the Visual Studio C Sharp project. Code throws an error ' The type 'IDbColumnSchemaGenerator' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Common, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. NuGet Microsoft.Data.SqlClient is showing as installed. have tried the following console commands

1.'dotnet nuget locals all --clear

2.'dotnet restore

3.'dotnet clean

4.'dotnet build - error 'build failed. But NuGet Microsoft Data SqlClient is reported as installed in NuGet Browse tab

Developer technologies | C#
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
0 comments No comments
{count} vote

6 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 82,146 Reputation points Volunteer Moderator
    2025-10-09T23:13:25.72+00:00

    assembly 'System.Data.Common' is a framework 4.* assembly. it can not be used with dotnet core. you must have a 4.* framework library reference in your project. you will need to replace it with a dotnet core compatible library.

    0 comments No comments

  2. Starry Night 625 Reputation points
    2025-10-10T03:02:42.6366667+00:00

    You can try to follow the steps below to troubleshoot this problem.

    1. Open up your solution in Visual Studio.
    2. In Solution Explorer, right-click the References or Dependencies node, and then choose either Add Project Reference, Add Shared Project Reference, or Add COM Reference from the context menu. User's image
    3. Now the references window will open up - just select the correct DLL with your missing type and hit OK .
    0 comments No comments

  3. Tom Spence 25 Reputation points
    2025-10-10T10:03:30.5833333+00:00

    I have since tried to uninstall / re-install NuGet. Then new error returned -".....................\Microsoft.Data.SqlClient 6.1.2 failed to uninstall. Restart Visual Studio to finish the process." Consecutive restarts have not resolved issue - same error is repeated.

    Have then carried out complete uninstall / re-install of Visual Studio 2022, same error is still being repeated

    Screenshot 2025-10-10 105853.jpg

    0 comments No comments

  4. Bruce (SqlWork.com) 82,146 Reputation points Volunteer Moderator
    2025-10-10T15:53:21.5733333+00:00

    you can just delete the /obj & /bin folders to uninstall (if you get a file in use error, that's the same issue VS is having). then run:

    dotnet restore

    optionally you can edit the project file to remove the package reference.

    but the Microsoft.Data.SqlClient package is unrelated to the System.Data.Common assembly reference error.

    0 comments No comments

  5. Tom Spence 25 Reputation points
    2025-10-11T14:10:12.5233333+00:00

    Have deleted the \bin and \obj folders for the project & restarted VS, and didn't get any locked file errors - deletes completed ok. But same error is still being shown " package .....................\Microsoft.Data.SqlClient 6.1.2 failed to uninstall. Restart VS to finish process"

    Checked the project file, doesn't contain any reference to the SqlClient package.

    If i could get the Microsoft.Data.SqlClient library added to the project i'd be happy, no intention of using the system.Data.Common package for the project.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.