Entity Framework Core with SQLite: ASP.NET application holding onto database in memory

asp.net-core c# entity-framework-core sqlite

Question

Thanks in advance for your help.

I'm using my Mac to develop and ASP.NET Core application with SQLite as the database (when learning about SQLite and EF Core, I read through this tutorial: https://docs.microsoft.com/en-us/ef/core/get-started/netcore/new-db-sqlite). Migrations and updating the database schema are working, but it seems as though the ASP.NET application is holding onto the database in memory.

Two reasons I'm assuming this:

  1. When I use "DB Browser For SQLite" to browse the SQLite the database schema and data, it shows that there is no data in any of the table (schema is present, so migrations are writing to disk)
  2. When I deleted the SQLite database file itself, the ASP.NET site still had the old data from the deleted file! Really weird.

Does anyone know how I can have my application actually write out the data to the SQLite file, and prevent it from storing it in memory?

Thanks again!

DbContext file:

public class EssBomContext : DbContext
{
   public DbSet<Part> Parts { get; set; }
    // Other DbSets removed for brevety

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        optionsBuilder.UseSqlite("Data Source=sqlite.db");
    }
}
1
0
2/6/2018 5:25:49 AM

Accepted Answer

"How can I have the Web project use the db in the Data.EF project?"

Possibly optionsBuilder.UseSqlite("Data Source=\Data.EF\sqlite.db");

0
2/6/2018 3:54:24 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow