Database file for ASP.Net Core under Linux

Here is some information about the database of an ASP.Net Core project under Linux. This assumes the project was created using the Yeoman generator or a similar process.

What’s the database?

The database is SQLite which is an embedded database found as a *.db file.

Where can I find it?

You can find it in your /bin/debug folder. It will be named based on your project’s name. ie: MyProject.db.

How can I access it outside of my program?

There are GUI programs to access the database but you can also use the sqlite3 program which is installed by default on some Linux distributions.

To install it on a Debian/Ubuntu based distribution use the following command:

sudo apt-get install sqlite3

To run it use

sqlite3 /pathToDbFile/DbFile.db

Then you can use .tables to list tables, select * from AspNetUsers; to do a simple select and .exit to exit the program.

You can also use .mode line to get better formatted results when using select statements.

How to create/recreate it if something happens?

Use the dotnet ef command.

If you have deleted your database use

dotnet ef database update

If your database is in a broken state and you don’t mind losing your data (if it’s only been used during development for instance) I suggest deleting it and recreating it (again if you don’t mind losing your data).


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s