Search code examples
c#asp.netvisual-studio-2012nugetdapper

An error occurred while trying to restore packages: 'Dapper' already has a dependency defined for 'System.Data.SqlClient'


I am trying to run an old system on Visual Studio 2012. When I try to restore the packages using package manager console I got this error.

An error occurred while trying to restore packages:
'Dapper' already has a dependency defined for 'System.Data.SqlClient'

enter image description here

Then I tried to install Dapper 1.50, as suggested by another question and got the following error kept showing up.

NuGet\Install-Package : 'Dapper' already has a dependency defined for 'System.Data.SqlClient'.
At line:1 char:1
NuGet\Install-Package Dapper -Version 1.50.5

CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand

Then I tried uninstalling dapper and got the following error.

NuGet\uninstall-Package : Unable to find package 'Dapper'.
At line:1 char:1
NuGet\uninstall-Package Dapper

CategoryInfo : NotSpecified: (:) [Uninstall-Package], InvalidOperationException
FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.UninstallPackageCommand

Is there any steps I can follow to fix these issues?


Solution

  • Dapper 1.50.5 is ancient (2018) and includes a System.Data.SqlClient dependency. In short: don't use the ancient thing; "current" is 2.1.35 at the time of writing, and does not have any such dependency. So... use that. This still supports down to .NET Framework 4.6.1. If you need something earlier than that... good luck!