Which version of SQLite do you have ?
For Ubuntu or Linux system, You can install sqlite3 with below command
sudo apt install sqlite3
Next We should have dotnet entity framework tool plus required packages.
dotnet tool install --global dotnet-ef
#add required packages
dotnet add package Microsoft.EntityFrameworkCore.Sqlite
dotnet add package Microsoft.EntityFrameworkCore.Design
After this We are going to verify reference and connection string in our DBContext implementation class,
We should use Microsoft.EntityFrameworkCore in the class, initialize constructor and configuration as below.
using Microsoft.EntityFrameworkCore;
public string DbPath { get; }
public MyDbContext()
{
var folder = Environment.SpecialFolder.LocalApplicationData;
var path = Environment.GetFolderPath(folder);
DbPath = System.IO.Path.Join(path, "myDBFileName.db");
}
// This configures EF to create a Sqlite database file in the
// special "local" folder for your platform.
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlite($"Data Source={DbPath}");
Now, We can use below commands to initiate migration and update our SQLite DB.
dotnet ef migrations add InitialCreate
dotnet ef database update