How to set threading mode in SQLite with Entity Framework?

entity-framework-core multithreading sqlite

Question

I'm using SQLite with Entity Framework Core (RC1).

I read, that SQLite supports three different threading modes: Single-thread, Multi-thread and Serialized.

How do I set in run-time, which mode I want to use with my database?

1
1
6/14/2016 1:54:17 PM

Accepted Answer

Microsoft.Data.Sqlite references the official SQLite NuGet package. That package contains a version of SQLite that has been compiled with SQLITE_THREADSAFE=1 (Serialized). Microsoft.Data.Sqlite doesn't currently expose an API to change this, nor did System.Data.SQLite.

See also aspnet/EntityFramework#5466.

2
6/14/2016 5:43:26 PM

Popular Answer

It is accomplished by opening a database with the appropriate flags set. SQLITE_OPEN_NOMUTEX for multithread or SQLITE_OPEN_FULLMUTEX for serialized. It looks like flag setting is available through the C interface:

https://www.sqlite.org/c3ref/c_open_autoproxy.html

So if you aren't using the C interface directly, you are at the mercy of EF and whether they have decided to support flag setting on database open.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow