LiteDB icon indicating copy to clipboard operation
LiteDB copied to clipboard

Exception: Datafile is not a LiteDB database.

Open MestreDosMagros opened this issue 5 years ago • 13 comments

I think i found one of the reasons for the error: LiteDB.LiteException: Datafile is not a LiteDB database.

As i saw on other issues referecing this problem, is the database file that become kinda corrupt, but only when the system tryes to read, on the studio everything goes fine.

Im implementing the LiteDB in a very small project (.net core 2.2 console app as a windows service) and im using it just to keep track of the e-mails that im sending.

I faced this exception a bunch of times, then delete the db file and start again, but i noticed now, that i only have this problem when i read the file on the LiteDB Studio.

If i create a new file, everything goes fine until i open the database on the studio(dont tried on the shell), after i open the database on the studio i get this problem. Maybe the error is caused by it.

I dont have the time yet to investigate the code by my own, but im trying to help.

Cheers

MestreDosMagros avatar Oct 01 '19 13:10 MestreDosMagros

Hello @MestreDosMagros (kkkk, nick muito engraçado!!)

I will try to reproduce this steps to check this. v5 use lock FileOpen concepts to not allow 2 process open same database at same time (only if both are using Mode=Shared). Are you using Mode=Embeded?

mbdavid avatar Oct 01 '19 14:10 mbdavid

kkkk Valeu!

I'm using shared mode, but the problem exists even when i got just my console app running after i open the db file externally.

For example, my service created a database an run ok, then i make a copy of that db file, and open one copy externally on the studio, with that file i get the error running the app, when i swap the file and use the one i dont opened externally it runs fine.

MestreDosMagros avatar Oct 02 '19 17:10 MestreDosMagros

I'm having the same issue. I am using the latest 4.x version of LiteDB in my project, and the latest LiteDB Studio exe from github.

dfrencham avatar Oct 28 '19 21:10 dfrencham

Same here

maurocristy87 avatar Oct 29 '19 18:10 maurocristy87

Same here, exact same.

ghost avatar Oct 29 '19 19:10 ghost

+1

biapar avatar Nov 13 '19 14:11 biapar

We get it without even using studio. In very rare cases Store seems to fail, and after few failures to insert data, it starts to receive the error.

Pokis avatar Nov 22 '19 09:11 Pokis

+1

FAAAAT avatar Dec 08 '19 10:12 FAAAAT

+1 Opening db file with LiteDB Studio, app that created data file cannot open it again even when disconnected.

bkavuncu avatar Dec 14 '19 11:12 bkavuncu

+1

praiakov avatar Jan 10 '20 13:01 praiakov

+1

FarhadMohseni avatar Dec 06 '21 03:12 FarhadMohseni

+1

bar10dr avatar Nov 15 '23 10:11 bar10dr

+1

rf0ster avatar Mar 21 '24 22:03 rf0ster