if using vs code, install the sqlite plugin and validate the db file access. but most likely the path is wrong. also if the build is copying the db as content, be sure the permissions are correct.
.Net core application with EFCore using Sqlite DB on linux giving error "Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 14: 'unable to open database file'."
Hrushikesh Patel
0
Reputation points
I'm running a simple .Net Core application on Linux using EFCore and SQLite, but I'm getting the following error:
An exception occurred while iterating over the results of a query for context type 'ApplicationDbContext'. Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 14: 'unable to open database file'.
The same code is working fine on Windows. Below is an excerpt from the code:
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured)
{
optionsBuilder.UseSqlite($"Data Source={DbPath}");
}
}
DBPath is properly formed inside Linux, as the same path can read a normal text file. The only issue is with the SqliteDB file.