Error opening MDB file on network location with EntityFrameworkCore.jet.oledb 3.1

206 Views Asked by At

I have a project opening up MS Access DBs on a network folder. The project is a .net core 3.1 webapi. EDIT: I'm using EntityFrameworkCore.Jet.OleDb v3.1 with provider in connection string Provider=Microsoft.ACE.OLEDB.12.0.

It very simply updates a list of boards based on new ones

public void SyncBoards(List<Board> boards)
{
    _cutriteDbContext.RemoveRange(boards);
    _cutriteDbContext.SaveChanges();
    _cutriteDbContext.AddRange(boards);
    _cutriteDbContext.SaveChanges();
}

I'm getting the error (sanitized)

System.Data.OleDb.OleDbException (0x80004005): The Microsoft Access database engine cannot open or write to the file '\{SHAREDFOLDER}{PATH_TO_FILE}\imatv11.mdb'. It is already opened exclusively by another user, or you need permission to view and write its data.

This works fine in IIS Express when debugging from VS 2019. I believe this is because the API doesn't have the credentials to access the file. The DBs do not have password protection. Is there a way to provide credentials to the file?

1

There are 1 best solutions below

0
On

I had to set the identity in the IIS application pool in advanced settings.