FSharp.Data.SqlClient icon indicating copy to clipboard operation
FSharp.Data.SqlClient copied to clipboard

Improve error if SQL Types dependency is missing

Open isaacabraham opened this issue 8 years ago • 5 comments

If your database uses Geography types, the SQL Programmability Provider won't build unless your project references the Microsoft.SqlServer.Types package. The error is pretty spurious (just that it can't find the type) but there's no way to know why this is. It took me a while to realise it's because I added a Geography column to the DB.

Perhaps a better error message would help.

isaacabraham avatar Feb 22 '17 15:02 isaacabraham

@isaacabraham if you have a chance to debug this, the defintion seems to be https://github.com/fsprojects/FSharp.Data.SqlClient/blob/505ecc77471e9607193c4206a71b1abde975face/src/SqlClient/SqlClientExtensions.fs#L269 and we'd need to track down the place the type is actually loaded by the type provider.

Can you post a screenshot with actual behaviour?

smoothdeveloper avatar Feb 22 '17 15:02 smoothdeveloper

image

Once I add nuget Microsoft.SqlServer.Types 10.50.1600.1 to the Paket dependencies file, life is good.

Note that it must be that specific version, otherwise you pull down a newer version and get a binding redirect issue at runtime.

isaacabraham avatar Feb 22 '17 17:02 isaacabraham

I think the best solution might actually be to include the Microsoft.SqlServer.Types NuGet package as a dependency. I had to use the newer version (13.0.0.0) to work with latest Sql Server, so had to manually create a binding redirect for it. Paket couldn't know to add it because it's a "silent" dependency on the type provider.

isaacabraham avatar Feb 24 '17 09:02 isaacabraham

@isaacabraham if this is still an issue, would you be able to propose a PR that adds that dependency to the nuget?

Are there special considerations needed in context of TP and design time assemblies for this particular case?

smoothdeveloper avatar Apr 10 '19 14:04 smoothdeveloper

Sure, I will have a look at doing this. In terms of design-time / special considerations - I have no clue; with the Azure Storage TP which takes dependencies, I build against specific versions and bundle them with the TP itself, whilst simultaneously adding the dependency in the nuget spec.

isaacabraham avatar Apr 20 '19 10:04 isaacabraham