Type exists in both System.Data.Common and System.Data.SqlClient

146 Views Asked by At

I have a ASP.NET Core web application (.NET 8) with only one dependency:

<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.1" />

I'm trying to add the Exceptional library:

<PackageReference Include="StackExchange.Exceptional.AspNetCore" Version="2.2.32" />

I have existing code referring to System.Data.SqlDbType, and after adding Exceptional I get the following build error:

The type 'SqlDbType' exists in both 'System.Data.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'System.Data.SqlClient, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

How can I fix it?

1

There are 1 best solutions below

0
On BEST ANSWER

I figured just adding an explicit reference to the System.Data.SqlClient package solved the issue:

<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />