Editorials

SqLite and Dot net

Today I was working with an application where I create a SqLite database for an embedded device. I’ve been using the System.Data.SqLite package started on SourceForge years ago. It provides dot net device drivers for SqLite,

implementing the Ado.Net interfaces, allowing me to work with a database using traditional Ado.Net code. The library also supports Entity Framework, should you need that capability.

Today, I was looking for an update to the library. The reason I have been looking is that the Ado.Net implementation for the SqLite database was written using interop services. That means that the original SqLite DLL is managing the
database, and we are simply calling into the binary through Interop calls. Although this is not optimal, it is quite fast in my testing. The only problem I have experienced is that when I am working with a database hosted on the disk, and I close my last database connection, the connection handle is not removed in the DLL, so the file is still locked, even though my software thinks the connection has been closed.

The Ado.Net SqLite authors were aware of the bug, but no fix was available. If you go to System.Data.Sqlite.org you can see more about this long running library. It is still active, and has a version newer than the one I have been using.

Today I noticed there is a new player in the SqLilte space. I was fooled at first, thinking it was simply a 2.0 NuGet package updating the System.Data.SqLlite library. With a little more digging I found that this is actually a Microsoft product that has been developed as a part of the CORE initiative. The NuGet package is labeled “Microsoft.Data.SQLite 2.0.0”. You can find this package through NuGet, or follow this url: https://www.nuget.org/packages/Microsoft.Data.SQLite/2.0.0.

I haven’t tested this version yet, to see if it fixes my issue. But I’m looking forward to seeing how the Microsoft version behaves. SqLite is a great little SQL database, and it works well in certain environments. The best part is that it can run completely in memory with a very small footprint.

Cheers,

Ben