简体   繁体   English

使用MySQL在F#中配置SQLProvider时遇到问题

[英]Having trouble configuring SQLProvider in F# with MySQL

I'm new to set up and connect my F# code base to a MySQL database. 我是刚成立并将F#代码库连接到MySQL数据库的新手。 So far, these are the following steps I've taken. 到目前为止,这些是我已经采取的以下步骤。

  1. brew install mysql brew安装mysql
  2. set up and created username/password & database and started mysql server 设置并创建用户名/密码和数据库,并启动mysql服务器
  3. installed SQLProvider through NuGet 通过NuGet安装的SQLProvider
  4. I went to http://dev.mysql.com/downloads/connector/net/1.0.html and downloaded the MySql.Data.dll 我去了http://dev.mysql.com/downloads/connector/net/1.0.html并下载了MySql.Data.dll
  5. I took the MySql.Data.dll and moved it into {proj_path}/packages/SQLProvider.1.0.22/lib 我将MySql.Data.dll移到{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 MySql.Data.dll之一必须存在于路径中
{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

I think the resolutionPath might be incorrect since you are supposed to give location to MySql.Data.dll file, could you try 我认为resolutionPath可能不正确,因为您应该将位置分配给MySql.Data.dll文件,您可以尝试

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

and see if that helps? 看看是否有帮助?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM