Search code examples
mysqlf#type-providers

Having trouble configuring SQLProvider in F# with MySQL


I'm new to set up and connect my F# code base to a MySQL database. So far, these are the following steps I've taken.

  1. brew install mysql
  2. set up and created username/password & database and started mysql server
  3. installed SQLProvider through NuGet
  4. I went to http://dev.mysql.com/downloads/connector/net/1.0.html and downloaded the MySql.Data.dll
  5. I took the MySql.Data.dll and moved it into {proj_path}/packages/SQLProvider.1.0.22/lib

And I have the following code

namespace lukecxufs
open FSharp.Data.Sql

module test = 

  let [<Literal>] resolutionPath = __SOURCE_DIRECTORY__
  let [<Literal>] connectionString = "Data Source=localhost"
  type sql = SqlDataProvider< 
              ConnectionString = connectionString,
              DatabaseVendor = Common.DatabaseProviderTypes.MYSQL,
              ResolutionPath = resolutionPath,
              IndividualsAmount = 1000,
              UseOptionTypes = true >

I keep getting an error saying

Unable to resolve assemblies. One of MySql.Data.dll must exist in paths
{proj_path}/lukecxufs../../files/sqlite
{proj_path}/packages/SQLProvider.1.0.22/lib

Also, I'm using mono if it makes a difference

Here's my folder structure below.

├── api
│   ├── AssemblyInfo.fs
│   ├── Program.fs
│   ├── api.fsproj
│   ├── bin
│   │   └── Debug
│   │       ├── FSharp.Data.SqlProvider.dll
│   │       ├── Suave.dll
│   │       ├── api.exe
│   │       └── api.exe.mdb
│   ├── obj
│   │   └── x86
│   │       └── Debug
│   │           ├── api.exe
│   │           ├── api.exe.mdb
│   │           └── api.fsproj.FilesWrittenAbsolute.txt
│   └── paket.references
├── api.sln
├── api.userprefs
├── packages
│   ├── FSharp.Core
│   │   ├── FSharp.Core.4.0.0.1.nupkg
│   │   ├── FSharp.Core.nuspec
│   │   ├── [Content_Types].xml
│   │   ├── _rels
│   │   ├── lib
│   │   │   ├── net20
│   │   │   │   ├── FSharp.Core.dll
│   │   │   │   ├── FSharp.Core.optdata
│   │   │   │   ├── FSharp.Core.sigdata
│   │   │   │   └── FSharp.Core.xml
│   │   │   ├── net40
│   │   │   │   ├── FSharp.Core.dll
│   │   │   │   ├── FSharp.Core.optdata
│   │   │   │   ├── FSharp.Core.sigdata
│   │   │   │   └── FSharp.Core.xml
│   │   │   ├── portable-net45+monoandroid10+monotouch10+xamarinios10
│   │   │   │   ├── FSharp.Core.dll
│   │   │   │   ├── FSharp.Core.optdata
│   │   │   │   ├── FSharp.Core.sigdata
│   │   │   │   └── FSharp.Core.xml
│   │   │   ├── portable-net45+netcore45
│   │   │   │   ├── FSharp.Core.dll
│   │   │   │   ├── FSharp.Core.optdata
│   │   │   │   ├── FSharp.Core.sigdata
│   │   │   │   └── FSharp.Core.xml
│   │   │   ├── portable-net45+netcore45+wp8
│   │   │   │   ├── FSharp.Core.dll
│   │   │   │   ├── FSharp.Core.optdata
│   │   │   │   ├── FSharp.Core.sigdata
│   │   │   │   └── FSharp.Core.xml
│   │   │   ├── portable-net45+netcore45+wpa81+wp8
│   │   │   │   ├── FSharp.Core.dll
│   │   │   │   ├── FSharp.Core.optdata
│   │   │   │   ├── FSharp.Core.sigdata
│   │   │   │   └── FSharp.Core.xml
│   │   │   └── portable-net45+sl5+netcore45
│   │   │       ├── FSharp.Core.dll
│   │   │       ├── FSharp.Core.optdata
│   │   │       ├── FSharp.Core.sigdata
│   │   │       └── FSharp.Core.xml
│   │   └── package
│   │       └── services
│   │           └── metadata
│   │               └── core-properties
│   │                   └── bb309a7e309548529b66e5b42059dbb1.psmdcp
│   ├── MySql.Data
│   │   ├── CHANGES
│   │   ├── MySql.Data.6.9.9.nupkg
│   │   ├── MySql.Data.nuspec
│   │   ├── Readme.txt
│   │   ├── [Content_Types].xml
│   │   ├── _rels
│   │   ├── content
│   │   │   ├── app.config.transform
│   │   │   └── web.config.transform
│   │   ├── lib
│   │   │   ├── net40
│   │   │   │   └── MySql.Data.dll
│   │   │   └── net45
│   │   │       └── MySql.Data.dll
│   │   ├── license.html
│   │   └── package
│   │       └── services
│   │           └── metadata
│   │               └── core-properties
│   │                   └── 8a5d4fe3e48745aea7a6ec39787d6703.psmdcp
│   ├── SQLProvider
│   │   ├── SQLProvider.1.0.22.nupkg
│   │   ├── SQLProvider.nuspec
│   │   ├── [Content_Types].xml
│   │   ├── _rels
│   │   ├── lib
│   │   │   └── FSharp.Data.SqlProvider.dll
│   │   └── package
│   │       └── services
│   │           └── metadata
│   │               └── core-properties
│   │                   └── addc797a97984054a5bf88ae510977a5.psmdcp
│   └── Suave
│       ├── Suave.1.1.3.nupkg
│       ├── Suave.nuspec
│       ├── [Content_Types].xml
│       ├── _rels
│       ├── lib
│       │   └── net40
│       │       ├── Suave.dll
│       │       ├── Suave.pdb
│       │       └── Suave.xml
│       └── package
│           └── services
│               └── metadata
│                   └── core-properties
│                       └── bfd111f5611143d39dfd308db403a690.psmdcp
├── paket.dependencies
└── paket.lock

Solution

  • I think the resolutionPath might be incorrect since you are supposed to give location to MySql.Data.dll file, could you try

    let [<Literal>] resolutionPath = __SOURCE_DIRECTORY__ + "/packages/SQLProvider.1.0.22/lib/"
    

    and see if that helps?