Linked Questions

120 votes
18 answers
61k views

System.Data.SQLite Close() not releasing database file

I'm having a problem closing my database before an attempt to delete the file. The code is just myconnection.Close(); File.Delete(filename); And the Delete throws an exception that the file ...
  • 1,763
10 votes
2 answers
4k views

DbContext doesn't release SQLite database

First, these are my intentions: Create a DbContext on SQLite Read and write from/to it Close context Move the file to another location Points 1-3 work perfectly. The problem starts when I try to ...
  • 233
0 votes
3 answers
3k views

Checking if Table Exists Keeping Connection Open in SQLite

So I have a method which is supposed to check if a table exists in a database which is defined as follows: internal override bool TableExists(string tableName) { bool tableExists = false; // ...
  • 12.4k
1 vote
0 answers
2k views

Delete sqlite database file in .net environment

I'm doing some integration tests of a software which uses SQLite. The software needs to use a database file to prevent data being lost. After each of the tests, I want to delete the database file to ...
0 votes
2 answers
635 views

Writing to hard disk Error - Too many open files

During some process, I'm storing objects to a file (serialization). Each batch will store 100 files. I'm quickly getting "Too many open files" error. I'm closing the StreamWriter immediately after ...
  • 1,101
1 vote
2 answers
802 views

How to dispose SQLiteCommands created internally by Entity Framework?

I have problems with System.Data.SQLite (v1.0.94.0) writing "SQLite error (5): database is locked" to the log when opening a new connection. This seems to be caused by Entity Framework (v6.0) not ...
1 vote
0 answers
421 views

Database is locked using SQLite in C#

When ExecuteNonQuery(), my database gets locked but if I comment that part ExecuteReader works fine. How to avoid database getting locked? I know that first is a write into database when creating ...
2 votes
1 answer
161 views

SQLite file locked after closing

Aware of System.Data.SQLite Close() not releasing database file and SQLite keeps the database locked even after the connection is closed I originally tried Close, but added Dispose and the GC ...
  • 21
2 votes
1 answer
153 views

Deleting file held by another process when Task is cancelled

I am having an issue when I create a file (an Sqlite Database) inside a long-running Task I cannot properly delete it if the task was cancelled. It throws an IOException about being used in another ...
  • 3,382
0 votes
2 answers
77 views

Using Mode=ReadWriteCreate doesn't create the database in some scenarios in Microsoft.Data.Sqlite

Currently, I am trying to completely delete an Sqlite database and recreating it if a database corruption is detected. However, when I: Create the database using Mode=ReadWriteCreate Delete it ...