You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Sqlite: Create databases with journal_mode=WAL #14059
But in general, using WAL mode is good, and will probably be the right choice for most users. I use WAL mode all the time on all of my projects.
That said, a wrapper that automatically sets WAL mode can be a problem. The sqlite-net library recently made a change to use WAL mode all the time, and it has caused a number of problems.
If you make this change to EF Core, it will probably benefit most users, but it will very likely cause trouble for somebody.
I would agree that making this kind of change at a higher abstraction layer (like EF Core) is much more appropriate to consider than at lower layers (like the ADO.NET provider).
I’d like to mitigate the risk by only setting it on new databases (not for every connection). If you find out that you don’t want it, you can just send the PRAGMA in a migration or something to disable it.
Please, if you do, give the developers a working opportunity to opt out. I have an app which use sqlite-net and their defaulting to WAL in the connection constructor in the latest version completely broke my export data functionality, which relayed on the fact that all the data was in the sqlite file, which is no more true when WAL is enabled. Tried to invoke PRAGMA wal_checkpoint(FULL) before exporting, but this only mitigate the issue, in that most often than not the most recent data are not copied from the -wal file to the sqlite one.
Also, closing the connection does not force the -wal file to be emptied (maybe a bug in sqlite-net implementation, I don't know).
Disabling WAL with pragma journal_mode does not work either consistently (that is: almost never).
If someone knows a proper way to export data when WAL is enabled I would be glad to know, but still, I think that is better to have the choice to opt out at the constructor level.
Reacted by Ryan Morehart, Martin, ahdung, JB1592, mfusiki, Koichi Tanaka and ulrichb
Activity
bricelam commentedon Dec 1, 2018
@ericsink Any reason not to? (in EF Core, not the ADO.NET provider)
ericsink commentedon Dec 1, 2018
IMO, WAL mode in general is better for ~98% of cases.
#ifdef QUIBBLENote that it is not universally true that WAL mode is faster. In fact, in some cases involving reads, it's slower: https://www.sqlite.org/wal.html#performance_considerations
#endifBut in general, using WAL mode is good, and will probably be the right choice for most users. I use WAL mode all the time on all of my projects.
That said, a wrapper that automatically sets WAL mode can be a problem. The sqlite-net library recently made a change to use WAL mode all the time, and it has caused a number of problems.
See praeclarum/sqlite-net#765 for more info.
If you make this change to EF Core, it will probably benefit most users, but it will very likely cause trouble for somebody.
I would agree that making this kind of change at a higher abstraction layer (like EF Core) is much more appropriate to consider than at lower layers (like the ADO.NET provider).
bricelam commentedon Dec 1, 2018
I’d like to mitigate the risk by only setting it on new databases (not for every connection). If you find out that you don’t want it, you can just send the PRAGMA in a migration or something to disable it.
effpath999 commentedon Jan 19, 2019
Please, if you do, give the developers a working opportunity to opt out. I have an app which use sqlite-net and their defaulting to WAL in the connection constructor in the latest version completely broke my export data functionality, which relayed on the fact that all the data was in the sqlite file, which is no more true when WAL is enabled. Tried to invoke PRAGMA wal_checkpoint(FULL) before exporting, but this only mitigate the issue, in that most often than not the most recent data are not copied from the -wal file to the sqlite one.
Also, closing the connection does not force the -wal file to be emptied (maybe a bug in sqlite-net implementation, I don't know).
Disabling WAL with pragma journal_mode does not work either consistently (that is: almost never).
If someone knows a proper way to export data when WAL is enabled I would be glad to know, but still, I think that is better to have the choice to opt out at the constructor level.
SQLite: Create new databases with WAL journal mode
ahdung commentedon Mar 24, 2023
So how to disable WAL today?
bricelam commentedon Mar 24, 2023
@ahdung After the database is created by EF, you can turn off WAL using by ececuting this SQL on it:
ahdung commentedon Mar 25, 2023
@bricelam Thank you very much.
dgxhubbard commentedon Aug 7, 2025
roji commentedon Aug 8, 2025