Litedb: Invalid connection string when using shared mode

Created on 2 Mar 2017  路  4Comments  路  Source: mbdavid/LiteDB

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.

question

All 4 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rstat1 picture rstat1  路  3Comments

axelgenus picture axelgenus  路  3Comments

GW-FUB picture GW-FUB  路  3Comments

darcome picture darcome  路  3Comments

sandolkakos picture sandolkakos  路  3Comments