Reputation: 1128
I'm trying to use SQLProvider to access MySql database. So far I have this code:
let [<Literal>] resolutionPath = @"../mysql/"
let [<Literal>] connectionString =
"Server=localhost;Database=mydb;User=root;Password=root"
type sql = SqlDataProvider<
ConnectionString = connectionString,
DatabaseVendor = Common.DatabaseProviderTypes.MYSQL,
ResolutionPath = resolutionPath,
IndividualsAmount = 1000,
UseOptionTypes = true >
let ctx = sql.GetDataContext ()
After some trouble I've managed to compile this code, and it even connects to my local database.
Unfortunately there is no autocompletion for ctx members (F# treats ctx as an object type). When I do something like:
ctx.``some_table``
it won't compile.
I have the same issues when trying to connect to Sqlite or PostgreSQL database. I'm on macOS 10.12 and I'm using newest mono and SQLProvider version (from nuget). Does anyone had similar problems on unix? Are there any other type providers for an sql database (that work not only on windows)? I saw that there is also SqlDataConnection, doest it work on macOS/linux and MySql?
Upvotes: 4
Views: 294
Reputation: 4027
Very late response, and I know this doesn't apply exactly to mysql but see this: F# Connect SQLProvider with Postgres. It might be a similar issue.
I managed to get it working in Visual Studio Code and Rider, after many restarts of the software. I basically created a lib folder inside the probject, I copied:
System.Runtime.CompilerServices.Unsafe.dll
System.Threading.Tasks.Extensions.dll
System.Memory.dll
Npgsql.dll
Upvotes: 1