Hi,
I am trying to open the database in shared mode. However I am getting this error:
Unhandled exception: LiteDB.LiteException: Invalid connection string value type for [mode]
This is how I access the database:
using (var db = new LiteDatabase("Filename=Database.db;Mode=Shared"))
{
...
}
I am using .net core 1.1.
Hi @onurhb, there is not Shared mode in netstandard. NetStandard do not support FileStream.Lock/Unlock methods (at least in v1.6... it麓s on roadmap to v2).
In NetStandard you must use Exclusive mode only. Try use a single instance only (it麓s support multi-thread).
Adding it to the dependency injection as singleton works:
services.AddSingleton<IDatabaseRepository, DatabaseRepository>();
For some reason, I was using AddTransient which creates one instance per object. This fixes my problem. Thanks for reply.
Any thoughts on this now that netstandard2.0 has been released?
@sgrassie, I'm thinking in update to v4 final release. I will remove 1.3 support to add only 2.0