SQLite in .NET 6
(1) By anonymous on 2022-09-26 09:52:43 [source]
Hello
Is there a sample how to implmenent System.Data.SQLite in .NET 6?
I get the error System.Data.Entity.Core.MetadataException: 'Unable to load the specified metadata resource.'
Thanks Urs
(2.1) By Chris Locke (chrisjlocke1) on 2022-09-26 10:32:43 edited from 2.0 in reply to 1 [link] [source]
.Net obviously covers a range of languages. There is also a sub-range of flavours - core, framework, etc.
I'll go through the steps I do with vb.net.
Go to the download page for system.data.sqlite.dll
About halfway down you'll see the precompiled binaries for .net 4.6 - grab the 32-bit and 64-bit versions. At the top of the page, it'll explain you'll need the .dll with the .exe, and the interop.dll in a x86 and x64 directory.
In your project, just reference the system.data.sqlite.dll and you should be good to go.
(3) By anonymous on 2022-09-26 11:17:40 in reply to 2.1 [link] [source]
I have a C# application .NET 4.8 EF 6 app which I want to port to .NET 6 with EF 6 not EF Core. I do not find a sample of this kind.
(4) By Chris Locke (chrisjlocke1) on 2022-09-26 12:15:23 in reply to 3 [link] [source]
The SQLite files you need should be the same.
You can also go down the Nuget route, but this also works.
(5) By anonymous on 2022-09-26 14:23:36 in reply to 4 [link] [source]
I think it is almost the same except this two lines of code instead of xml configuration.
DbProviderFactories.RegisterFactory("System.Data.SQLite.EF6", System.Data.SQLite.EF6.SQLiteProviderFactory.Instance);
DbProviderFactories.RegisterFactory("System.Data.SQLite", System.Data.SQLite.SQLiteFactory.Instance);
(6) By anonymous on 2024-02-16 23:23:02 in reply to 4 [link] [source]
Hi Chris, Another anonymous here :)
Could you suggest a Nuget package for working with SQLite under .NET 6 C#? I used to use System.Data.SQLite namespace in 4.8 full framework but I cannot remember whether it had EF among its dependencies. The versions currently on Nuget are System.Data.Sqlite 1.0.118 and System.Data.Sqlite.EF6 1.0.118. When I tried to install the former it came with EF6 dependencies. Since I do not use EF I thought I'd ask you first before bloating my project by the EF assemblies.
Thank you for all of your work on SQLite that I enjoy the fruits of so much!
Al
(7.1) By Chris Locke (chrisjlocke1) on 2024-02-17 09:51:20 edited from 7.0 in reply to 6 [link] [source]
I just use the .Net 4.6 versions linked in post 2.1 .. they're still valid for .Net 6. Its just three DLLs, and there is no EF baggage. Nor other Nuget bloaty stuff .. just the DLLs.
So this: https://system.data.sqlite.org/downloads/1.0.118.0/sqlite-netFx46-binary-Win32-2015-1.0.118.0.zip And this: https://system.data.sqlite.org/downloads/1.0.118.0/sqlite-netFx46-binary-x64-2015-1.0.118.0.zip
This is for v1.0.118.
Thank you for all of your work on SQLite
I'm not part of the SQLite team and don't have any dealings with them .. I'm just a bog standard user.
(8) By anonymous on 2024-02-17 13:50:22 in reply to 7.1 [link] [source]
Great, thanks! :)
(9) By anonymous on 2024-04-10 20:49:47 in reply to 8 [link] [source]
Everything was fine with using the referenced DLL for as long as it was a .NET 4.8 project under Windows 10. When someone tried to deploy it to a Windows 7 and 8.1 machines (yes, still have users on the trusty old 7&8) it threw exceptions from Sqlite connection Open() call. Those machines have .NET 4.8 installed all right. A quick sanity check shows that System.Data.SQLite.dll is deployed with the app.
************** Exception Text ************** code = CantOpen (14), message = System.Data.SQLite.SQLiteException (0x87AF03F3): unable to open database file at System.Data.SQLite.SQLite3.Open(String strFilename, String vfsName, SQLiteConnectionFlags connectionFlags, SQLiteOpenFlagsEnum openFlags, Int32 maxPoolSize, Boolean usePool) at System.Data.SQLite.SQLiteConnection.Open()
It tries to create a new DB under the user's AppDataRoaming which succeeds on my W10 dev machine after I blow the DB away and start fresh.
(10) By Chris Locke (chrisjlocke1) on 2024-04-10 22:23:15 in reply to 9 [link] [source]
Have you installed the C++ runtimes as per the sqlite download page? They're probably already baked into Win 10, but probably not Win 7 or 8.
I recommend following the instructions. They're written to prevent people scratching their heads. A lot of effort has gone into those instructions.