I'm making a small web app which currently is using sqlite
+ EF Core 2.1
for storing data. Are there any solutions that I can sandbox my sqlite database file ?
I mean to load my sqlite database with its data and triggers from my physical db file into memory.
Everytime when I turn on/off VS debugger, database will be refreshed with my existing data in physical file .
Thank you,
Here's some code that literally does what you asked:
var sandboxConnection = new SqliteConnection("Data Source=:memory:");
sandboxConnection.Open();
using (var physicalConnection = new SqliteConnection("Filename=physical.db"))
{
physicalConnection.Open();
physicalConnection.BackupDatabase(sandboxConnection);
}
optionsBuilder.UseSqlite(sandboxConnection);
Move the physical sqlite file outside of the web root in a secure folder. SqliteCipher can also be used to encrypt
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.