SQLProvider
SQLProvider copied to clipboard
Unclear exception in sqlite type provider in .net core 3.1 project
Describe the bug In a netcoreapp3.1 project creating a SqlTypeProvider with provider type SQLITE yields a vague exception
To Reproduce Steps to reproduce the behavior:
- Create a new console app project, target .net core 3.1
- Create an empty database
- Install SQLProvider and Microsoft.Data.Sqlite nuget packages
- Type the following code in Program.fs file:
open FSharp.Data.Sql
[<Literal>]
let connectionString =
"Data Source=" +
__SOURCE_DIRECTORY__ + @"\BarDb.db;" +
"Version=3;foreign keys=true"
type sql = SqlDataProvider<
Common.DatabaseProviderTypes.SQLITE,
connectionString,
SQLiteLibrary = Common.SQLiteLibrary.MicrosoftDataSqlite,
CaseSensitivityChange = Common.CaseSensitivityChange.ORIGINAL>
- Build a project
- See error
Expected behavior Code compiles without errors
Actual behavior An error is displayed:
Error FS3033 The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error: Exception has been thrown by the target of an invocation.
Desktop
- OS: Windows 10 version 1909
- .NET SDK: .net core 3.1.301
I think you need to add ResolutionPath static parameter and put there the correct libraries (probably x86 versions if you run in Visual Studio).
I think you need to add ResolutionPath static parameter and put there the correct libraries (probably x86 versions if you run in Visual Studio).
Which ones? I googled e_sqlite3.dll but couldn't understand where I can acquire one and which version. Also, why x86?
I am also having this issue. I put System.Data.SQLite.dll in my source directory and I get an unclear "The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error: Exception has been thrown by the target of an invocation.". My code:
[<Literal>]
let ConnectionString = "Data Source=" + __SOURCE_DIRECTORY__ + @"/../transactions.db;"
type Database =
SqlDataProvider<
Common.DatabaseProviderTypes.SQLITE,
ConnectionString = ConnectionString,
ResolutionPath = __SOURCE_DIRECTORY__,
CaseSensitivityChange = Common.CaseSensitivityChange.ORIGINAL>
I have the same issue, did you find any solutions regarding this mater?
Cross-posted from https://www.reddit.com/r/fsharp/comments/16bq1da/sqlitesqlprovider_on_arm64_linux_mac/
I could successfully call raw SQL API from Microsoft.Data.Sqlite but when I wrote
type sql = SqlDataProvider<
DatabaseVendor = DatabaseProviderTypes.SQLITE,
SQLiteLibrary = SQLiteLibrary.MicrosoftDataSqlite,
ResolutionPath = "symlink/to/dir/containing/SQLitePCLRaw.core.dll",
...snip...
I got this error
error FS3033: The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error: You need to call SQLitePCL.raw.SetProvider(). If you are using a bundle package, this is done by calling SQLitePCL.Batteries.Init()
Microsoft.Data.Sqlite seems to call .Init() as required by SQLitePCL.raw but maybe the type provider evaluator (?) runs before that? Could anyone provide insights into what might be causing this issue?
.NET 7 on M1 Mac