'How to set threading mode in SQLite with Entity Framework?
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?
Solution 1:[1]
Microsoft.Data.Sqlite
references the SQLitePCRaw.bundle_e_sqlite3
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.
Solution 2:[2]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | andrew |