I want to install SQLite, using entity framework, code first.
This is not answered in this question: What SQLite Nuget Package do I need? That is about SQLite without entity framework.
There are a lot of Nuget SQLite packages, some from MicroSoft, some from SQLite, and there is also a SQLite.Org
In visual studio, using the Nuget Package Manager, I started with Nuget package Sqlite.CodeFirst. That gave me SqlIte.CodeFirst + Entity framework.
const string dbConnectionString = "Data Source=..." // full path to db file name
using (var dbContext = new SchoolDbContext(dbConnectionString)
{
bool dbCreated = dbContext.Database.CreateIfNotExists();
}
Alas, that does not work, the program does not return from this function. Perhaps I should install a different package.
Try: nuget System.Data.SQLite.EF6. Compiles, but also does not return from CreateIfNotExist.
OnModelCreating is called:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
}
However after I return from this method, nothing happens.
I also noticed that SQLiteConnectionStringBuilder
is only available in the MicroSoft SQLite version.
So what package(s) should I download from nuget, to be able to use SQLite with a fairly modern EF version, code first?
Normally the tables are created automatically. Should I create them her in OnModelCreating, because SQLite doesn't do that for me?