I'm developing a small app with multithreading. I decided to use LiteDB for storing data. I was able to read, update, delete and insert on my database successfully . However, when I tried to add another thread which is also going to use same database and same table throws an exception saying that
System.IO.IOException: 'The process cannot access the file 'C:\Users\Soyuz\TestApp\bin\Debug\Soyuz.db' because it is being used by another process.'.
This is how I established a connection to my db:
using (var db = new LiteDatabase(@"Soyuz.db")) { }
Here the document says, LiteDB offers 2 types of connections. I suppose I have to use shared one since I will have to access the same database from different threads.
https://www.litedb.org/docs/connection-string/
but when I tried this code;
using (var db = new LiteDatabase(@"Soyuz.db; Connection=shared")) { }
or
using (var db = new LiteDatabase(@"Soyuz.db; Mode=Shared")) { }
this time, it throws another exception saying that
System.ArgumentException: 'EngineSettings must have Filename or DataStream as data source'
Can someone who has an experience with LiteDB help me out with this please?