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).


Shell Script to update master

I was tired of always typing in the same commands to update my GitHub forks so I added this small shell script in /usr/local/bin (so it’s accessible from everywhere):

git fetch upstream
git merge upstream/master
git push origin master

So I can update my master branch quickly. I always work in feature branches so the merge from upstream is always a fast forward.

I named it update-master. Don’t forget to chmod 755.

Remapping Cap locks in a Debian based distro

I remap my Caps lock key on all my systems. Caps lock is a pretty useless key that’s sadly situated on the home row, the keyboard row where you naturally rest your hands while touch typing.

Having such a useless key on a such a prime piece of keyboard real estate is a waste.

There are popular alternative mappings, the Ctrl key being one of them. I myself prefer remapping Caps lock to another Escape key. I’m a Vim user and pressing Escape to exit insert mode is really a strectch.

Previously on Linux systems I used the xmodmap utility, created a file in my home directory which I loaded in my .bashrc.

Having recently installed Debian wheezy and Crunch Bang (#!) on two machines I found out that in Debian there is a keyboard file in /etc/default/ (/etc/default/keyboard) where you can set those options. No need to create a file and edit your .bashrc.

Here’s how you would remap Caps lock to act as another Escape:


The command:

grep "caps:" /usr/share/X11/xkb/rules/base.lst

Will allow you to list other possible options (Control, Backspace, etc.). If you don’t have access to /etc/default/keyboard you can always use xmodmap.

Note that you will have to use dpkg-reconfigure or reboot for the changes to take effect.