This is a real life example which demostrates how to use SQLite encrypted databases using Entity Framework Core (EFCore).
The database is using SQLCipher encryption. To create/explore SQLite databases with encrytion manually, you may use the open source DB Browser for SQLite, which you can find here https://sqlitebrowser.org/ or on GitHub https://github.com/sqlitebrowser/sqlitebrowser .
This example is using .Net Core 3.1 with EFCore 3.1.6 and SQLCipher 2.0.3:
- Add a NuGET reference to Microsoft.EntityFrameworkCorein your project
- Add a NuGET reference to Microsoft.EntityFrameworkCore.Designin your project
- Add a NuGET reference to Microsoft.EntityFrameworkCore.Sqlite.Corein your project This is a really important step: DO NOT add a reference to Microsoft.EntityFrameworkCore.Sqlite, otherwise it will not work!
- Add a NuGET reference to SQLitePCLRaw.bundle_e_sqlcipher
- Create a connection object (SqliteConnection), defining the database access password in the connection string (you can useSqliteConnectionStringBuilder) you give to the constructor
- Give the connection object to the UseSqlitemethod, when configuring the database context