When I try to use Entity Framework Core with Sqlite and a file extension of .db
or .sqlite
, I get an error
SqliteException: SQLite Error 14: 'unable to open database file'
If I remove the file extension, then it works fine.
I'm not very familiar with Entity Framework Core, and have been using things like npoco in the past. I'm working on a DataStorage and DataAggregator and I'm experiencing issues that require implementation of some hackery. I don't like it and it makes me feel dirty.
If I remove the .db
from the connection string, then it works just fine, but if I leave any file extension on (I've only tried .db
and .sqlite
), I get that error.
Steps to recreate:
dotnet run
this solution (or play with the Unit Tests) and go to AggregateResults ControllerAction in your browser. It will try to find all files that end in.db
and all that end in_db_metadata.json
and will find none and will return "0" to the browser page.Now go to the
DataStorageService\DataStorageService\TransmittedFiles
repository and clear it out. Go toEndpoints\DataStorage\AggregateData\AggregateDataContext.cs
. Comment out the linesif (OperatingSystemHelpers.IsOSWindows)...
up until
.Remove(connectionStringFileLocation.Length - 3);
Try to do exactly what you did before and you will see that 1) the AggregateData.db file is still created in TransmittedFiles, and 2) you should see the SqliteError 14.
If you clear the TransmittedFiles folder out again and try it with the OperatingSystemHelpers Clause back in, you'll see that it works. Meaning it isn't a matter of the file not existing.