.NET SQLite database is locked

I got following exception when I tried to modify the SQLite database using Entity Framework

System.Data.Entity.Core.EntityException: System.Data.Entity.Core.EntityException: An error occurred while starting a transaction on the provider connection. See the inner exception for details. ---> System.Data.SQLite.SQLiteException: database is locked
database is locked.


The code causing the problem is following (the orderDao and productDao is wrapper of Entity Framework to manipulate SQLite database)


One common situation to cause this problem is that another application is accessing the same database.


In my situation it's because that I opened the database with DB Browser for SQLite, deleted a database table and not applying the changes.

Clicking Write Changes (or Revert Changes or Close Database) and the error will be gone.