isaacabraham / get-programming-fsharp

Companion code repository for https://www.manning.com/books/get-programming-with-f-sharp
124 stars 57 forks source link

Lesson 32 SqlCommandProvider #55

Open StuartSchady opened 1 year ago

StuartSchady commented 1 year ago

I have tried using the

r "nuget: FSharp.Data.SqlClient, 2.1.2" via F# interactive, as well as referencing the .dll after I have built the project in both .Net and .netframework.

Everytime I try to execute the line of code:

#r "nuget: FSharp.Data.SqlClient, 2.1.2"

open System
open FSharp.Data

let [<Literal>] Conn = 
    @"Server=(localdb)\MSSQLLocalDb;Database=AdventureWorksLT;Integrated Security=SSPI"
type GetCustomers = SqlCommandProvider<"SELECT * FROM SalesLT.Customer", Conn>

I get this error:

error FS3021: Unexpected exception from provided type 'FSharp.Data.SqlCommandProvider,CommandText="SELECT * FROM SalesLT.Customer",ConnectionStringOrName="Server=(localdb)\\MSSQLLocalDb;Database=AdventureWorksLT;Integrated Security=SSPI"' member 'GetMethods': The type provider 'FSharp.Data.SqlCommandProvider' reported an error: The design-time type 'System.Data.SqlClient.SqlConnection' utilized by a type provider was not found in the target reference assembly set '[tgt assembly FSharp.Data.SqlClient, Version=1.0.0.0, Culture=neutral;
....
]'. You may be referencing a profile which contains fewer types than those needed by the type provider you are using.

If anyone knows how to solve this please let me know. Thanks