0

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?

Hey Mikey
  • 101
  • 6
  • Does the application have read and write permissions on the network share? Is there an .ldb lock file leftover in the database folder? – pjs Apr 02 '22 at 12:34
  • I'm not sure what account is being used under the hood for a web api. Is it always IIS_IUSRS or can it be set to something specific? Can we provide options in the DB config so that the code impersonates a specific account when opening the file? – Hey Mikey Apr 04 '22 at 12:26

1 Answers1

0

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

Dharman
  • 30,962
  • 25
  • 85
  • 135
Hey Mikey
  • 101
  • 6