[英]Sandbox Sqlite with EF Core
I'm making a small web app which currently is using sqlite
+ EF Core 2.1
for storing data. 我正在制作一个小型Web应用程序,当前正在使用sqlite
+ EF Core 2.1
来存储数据。 Are there any solutions that I can sandbox my sqlite database file ? 有什么解决方案可以沙箱化sqlite数据库文件吗?
I mean to load my sqlite database with its data and triggers from my physical db file into memory. 我的意思是将其数据和触发器的 sqlite数据库从我的物理db文件加载到内存中。
Everytime when I turn on/off VS debugger, database will be refreshed with my existing data in physical file . 每次我打开/关闭VS调试器时, 都会使用物理文件中的现有数据刷新数据库 。
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. 将物理sqlite文件移到Web根目录之外的安全文件夹中。 SqliteCipher can also be used to encrypt SqliteCipher也可以用于加密
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.