SQLProvider icon indicating copy to clipboard operation
SQLProvider copied to clipboard

Upgrading from 1.1.11: IDbConnection not found in reference assembly set

Open cmeeren opened this issue 8 years ago • 10 comments

I tried to upgrade from 1.1.11 to 1.1.20, but compilation now gives the the following error:

error FS3033: The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error: The type 'System.Data.IDbConnection' utilized by a type provider was not found in reference assembly set '[|ctxt assembly FSharp.Data.SqlProvider, Version=1.1.20.0, Culture=neutral; ctxt assembly mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089; ctxt assembly FSharp.Core, Version=4.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a; ctxt assembly System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089; ctxt assembly System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089; ctxt assembly System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|]'. You may be referencing a portable profile which contains fewer types than those needed by the type provider you are using.

This happens when trying to update to any version >= 1.1.12. Reverting to 1.1.11 fixes the issue.

The project in question is .NET Framework 4.7 class library. The latest FSharp.Core is installed via nuget.

Any idea what might be wrong or how I can debug this?

cmeeren avatar Nov 07 '17 07:11 cmeeren

Yes, it seems your project referenced the netstandard dll and not net451 dll like earlier. Both are now in the nuget package. Are you using Nuget or Paket or what...?

Thorium avatar Nov 07 '17 09:11 Thorium

Nuget in VS2017 15.4.2.

cmeeren avatar Nov 07 '17 09:11 cmeeren

I tried this initially and in my project it still took net451, so it would be interesting to know why this has happened.

Thorium avatar Nov 07 '17 09:11 Thorium

I'll happily provide any details you want (except the full project; it's a work project).

cmeeren avatar Nov 07 '17 09:11 cmeeren

I'm trying to reproduce this... Do you use the old or new fsharp project structure?

I expect the problem is this: Since 1.1.12 version, SQLProvider Nuget-package has two possible libraries:

lib\net451\FSharp.Data.SqlProvider.dll
lib\netstandard2.0\FSharp.Data.SqlProvider.dll

The first one is similar to 1.1.11 version, using the .NET Framework. The later has .NET Core support, but it needs a lot of framework-assemblies. So in your case the reference should be the first one.

System.Data.IDbConnection should be present in the .NET Framework 4.7 Do you have a reference to System.Data.dll in your project?

This site tells what reference dll should Nuget select, and as you see, by default it should choose the net451 for net47: http://nugettoolsdev.azurewebsites.net/4.2.0/get-nearest-framework?project=net47&package=net451%0D%0Anetstandard2.0%0D%0A%0D%0A

Thorium avatar Nov 07 '17 10:11 Thorium

I'm using the old project format. AFAIK the new one isn't supported in VS 15.4, which I'm using. (If there is a way to use the new format and/or .NET Standard 2.0, I'm very interested in that, but AFAIK that's not supported until 15.5.)

My fsproj contains no reference to System.Data. Here are all my references:

<ItemGroup>
  <Reference Include="FSharp.Data.SqlProvider">
    <HintPath>..\..\..\..\..\..\lib\NuGet\SQLProvider.1.1.11\lib\FSharp.Data.SqlProvider.dll</HintPath>
  </Reference>
  <Reference Include="mscorlib" />
  <Reference Include="System" />
  <Reference Include="System.Core" />
  <Reference Include="System.Numerics" />
</ItemGroup>

Adding a reference to System.Data fixes the problem:

  <Reference Include="FSharp.Data.SqlProvider">
    <HintPath>..\..\..\..\..\..\lib\NuGet\SQLProvider.1.1.20\lib\net451\FSharp.Data.SqlProvider.dll</HintPath>
  </Reference>
  <Reference Include="mscorlib" />
  <Reference Include="System" />
  <Reference Include="System.Core" />
  <Reference Include="System.Numerics" />
  <Reference Include="System.Data" />
</ItemGroup>

Is adding System.Data something that needs to be done manually?

cmeeren avatar Nov 07 '17 11:11 cmeeren

We are using System.Data manually, however I don't know why it has become a requirement since 1.1.11 as the original solution/project files are not modified.

Thorium avatar Nov 07 '17 19:11 Thorium

I just upgraded from 1.1.17 to 1.1.23 and had the same issue. Adding System.Data ref fixed it.

hoetz avatar Dec 04 '17 15:12 hoetz

Adding System.Data manually still seems to need to be done

mushishi78 avatar Sep 07 '19 12:09 mushishi78

Many thanks for this solution @Thorium. Adding System.Data reference fixed.

moviezhou avatar Mar 13 '20 03:03 moviezhou