It’s that time of year again. Microsoft.Data.Sqlite version 6.0.0 has been released today alongside the rest of .NET 6. Update now and let us know if you run into any issues.

Connection Pooling

The underlying, native SQLite connections are now pooled by default. This greatly improves the performance of opening and closing connections. This is especially noticeable in scenarios where opening the underlying connection is expensive as is the case when using encryption or in scenarios where there are lots of short-lived connections to the database. The Orchard Core benchmarks went from 5.5K to 14.5K requests per second with the latest version of Microsoft.Data.Sqlite.

Beware, however, that the database file may still be locked after you close a connection. If this becomes a problem, you can manually clear the pool to release the lock:

SqliteConnection.ClearPool(connection);

// or

SqliteConnection.ClearAllPools();

If you run into any issues, you can turn off connection pooling by specifying Pooling=False in your connection string. Please be sure to file an issue too!

Savepoints

This release implements the ADO.NET Savepoints API. Savepoints enable nested transactions. For more information and a sample, see the new Savepoints section in the docs.

DateOnly & TimeOnly

.NET 6 added two new types for working with date and time values. These types work just as you’d expect in parameters, data readers, and user-defined functions.

The little things

Here are a few more minor changes also worth mentioning:

  • Added the Command Timeout connection string keyword as part of an effort to standardize it across providers
  • Implemented the Span overloads of SqliteBlob to avoid allocations
  • Removed other unnecessary allocations and conversions between UTF-8 to further improve performance

Happy coding! Don’t forget to vote on the issues you’d like to see implemented in a future release.