我正在使用SQLProvider連接到我在F#中的本地PostgreSQL數據庫。 我已經開始使用此代碼fsprojects:Npgsql拋出一個錯誤:錯誤的連接字符串。無法連接到PostgreSQL [F#]
open FSharp.Data.Sql
open Npgsql
let [<Literal>] ResolutionPath =
__SOURCE_DIRECTORY__ + @"/../../packages/Npgsql/lib/net451/"
[<Literal>]
let connectionString = "Host=localhost;Port=5432;User ID=test;Password=test;Database=testdb;"
type PostgreSQL =
SqlDataProvider<
Common.DatabaseProviderTypes.POSTGRESQL,
ConnectionString = connectionString,
ResolutionPath = ResolutionPath,
IndividualsAmount = 1000,
UseOptionTypes = true>
當我試圖編譯它,我得到這個錯誤信息:
(path)/Database.fs(60,9): error FS3033: The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error: Could not create the connection, most likely this means that the connectionString is wrong. See error from Npgsql to troubleshoot: The type initializer for 'Npgsql.Counters' threw an exception. (path)/Database.fs(60,9): error FS3033: The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error: Could not create the connection, most likely this means that the connectionString is wrong. See error from Npgsql to troubleshoot: The type initializer for 'Npgsql.Counters' threw an exception.
我檢查該用戶ID和密碼,一切在連接字符串中是正確的。 我其實不知道如何調試這個問題。 你知道什麼可能是錯的? 它對你沒有任何問題嗎?
我使用的是macOS 10.12。
最後,如果我不能解決這個問題,有沒有其他方法,你會建議連接到PostgreSQL(與類型供應商)?
按照http://fsprojects.github.io/SQLProvider/core/postgresql.html –
嘗試用戶名而不是用戶標識 這兩個版本都不起作用,我試過「用戶名」而不是用戶ID,相同結果。 – mateuszlewko
我也會嘗試npgsql 3.1,如下面的答案,在Windows上也有一些3.2的問題。不包括大規模的.net核心依賴性下載,但至少可以清除那些。 – s952163