代码改变世界

vnext+sqlite3+sqlcipher

2022-08-16 15:00  Lecone.JY.HU  阅读(92)  评论(0编辑  收藏  举报

1.在abp.io网站上创建项目并选择数据库为sqlite。

2.默认情况下,sqlite是不加密的。

3.打开appsettings.json

"ConnectionStrings": {
    "Default": "Data Source=de.db;//You need to change to an absolute filename" 
  },

要改成

 "ConnectionStrings": {
    "Default": "Data Source=de.db;" 
  },

现在数据库是在运行目录下,如果要指定目录可以用绝对目录。

4.增加加密

 "ConnectionStrings": {
    "Default": "Data Source=de.db;password=123456;" 
  },

在配置文件中直接加上password会报错:You specified a password in the connection string, but the native SQLite library 'e_sqlite3' doesn't support encryption.”

在xxx.EntityFrameworkCore项目中加nuget :SQLitePCLRaw.bundle_e_sqlcipher ,

如果已经存在db文件,先删除后运行,不然报错。

 

 

参考网站

Entity Framework Core SQLite | Documentation Center | ABP.IO

的风格风格