sql-serverf#database-connectiondbcontextdbtype

F# Error FS3033 unsupported DbType 'Structured'


I’m trying to query our database in F# but I’m having a lot of errors when I get the data context. Here is my connection command:

#r "System.Data.dll"
#r "FSharp.Data.TypeProviders.dll"
#r "System.Data.Linq.dll"

open System
open System.Data
open System.Data.Linq
open Microsoft.FSharp.Data.TypeProviders
open Microsoft.FSharp.Linq

type dbSchema = SqlDataConnection<"Data Source=OCPM;Initial Catalog=Nautilus;Integrated Security=SSPI;">
let db = dbSchema.GetDataContext()

147 errors in total are returned after this simple script, I won’t list them all but here are a couple of examples:

I believe this is due to the complexity of the objects and structures used in our DB. The first error is due to a User-Defined Table Types called udt_IncidentExposure in the function utvf_VehiclesSummaryUDT. The second is because the temporary table #updatedPriceTab is called in asynch.usp_LBNGBasket but created in another stored procedures.

I’m surprised of the limited compatibility between F# and SQL Server on complex structures. Is there any other way to connect to SQL server in F#? All I need is doing very simples SQL queries.

Additional information: SQL Server version in use is 10.50.4270


Solution

  • You are out of luck with using production-quality SqlClient type provider because it requires at least SQL2012 to operate.

    You may try SQL Type Provider, although I do not have any experience using it in production scenarios.

    Also you may try using SqlEntityConnection type provider that sometimes does better job, than SqlDataConnection type provider that you've tried.

    And finally, as the last resort, nothing prevents you from accessing SQL from F# through plain ADO.NET.