Clock
Clock

Reputation: 984

Where is my SQLite database created?

I am following the tutorial presented here: EF7 tutorial

It seems to be a well-known tutorial about SQLite, UWP and EF7 all goes as expected when following it, but I was not able to find the physical path to the database created by the code-first approach.

This thing is quite strange I wanted to open the sqlite database using "DB Browser for SQL Lite" but I could not find it anywhere...

Did some of you follow this common tutorial and find the database or do you know where EF7 code first creates the database?

Upvotes: 5

Views: 6443

Answers (2)

Henk Holterman
Henk Holterman

Reputation: 273284

When you create an SQLite database without a specific path, it will be placed in the folder that your code can locate as Windows.Storage.ApplicationData.Current.LocalFolder

For your DB Browser, it is in

c:\Users\<username>\AppData\Local\Packages\<package-name>\LocalState\

<username> is obvious, <pacakage-name> can be found in your Package.appxmanifest, packaging tab. It looks like a Guid.

Upvotes: 6

Cleptus
Cleptus

Reputation: 3541

Wherever the executable is run. If you check the code linked, you find a relative path and a database name 'Blogging.db'. I would look in bin\Debug or bin\Release folders. You could search for the 'Blogging.db' file

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
    optionsBuilder.UseSqlite("Filename=Blogging.db");
}

Upvotes: 1

Related Questions