Using LiteDB in SAFE

I followed the quickstart on the SAFE website. Then I followed the ‘Quickly add a database’ recipe.

After compiling with dotnet run, the namespaces liteDB en LiteDB.FSharp are no longer recognised. Is there perhaps a compatablity issue?

Hi! Could you perhaps give some more details on what specific error you’re seeing? Could you say what your paket.dependencies and paket.references files look like? You say that those namespaces are “no longer recognised.” Were they recognized at some point? Do you know what step you were on when they stopped being recognized?

Sorry to throw so many questions at you, but I think we’re going to need a couple more details in order to help out.

Hey there. I would recommend that you raise an issue here: GitHub - SAFE-Stack/docs

If you could also copy out out any console error messages as well that would be really useful.

Thanks for your help.

The steps into this error are:
I use Visual Studio
in Console:
dotnet new SAFE
dotnet tool restore

Open the solution into VS
Add Nuget LiteDB.FSharp in server project.
import LiteDB in server.fs (open LiteDB)

in console
dotnet run

Errormsg in VS after compiling:
The namespace or module ‘LiteDB’ is not defined.

In Paket.dependencies or Paket.references are no references tot LiteDB. the content is unaltered.

When I add the nuget package while hot reloading is on (after dotnet run) then everything seems to be fine.

Thanks for your reply. Before I post an issue tot the docs, I want to be shure it is not just me :slight_smile:

Thanks for the details! I’ve never used paket+VS together, but I don’t think they can work together like that. The fact that your paket.dependencies and paket.references files are unaltered is definitely suspicious. Try adding LiteDB.FSharp to your project either via the dotnet paket add command, or by manually adding “LiteDB.FSharp” to your paket.dependencies and paket.references and then doing a dotnet paket install.

Thanks, I think that solved it.

You think SAFE is a smoother experience in VSC?

Oooh, great question.
I’m guessing paket is the only consideration. Paket has always been a bit more friendly to CLI tools than to the Visual Studio UI. But as long as you’re okay using paket from the CLI, I don’t think there’s any other gotcha’s for Visual Studio. I don’t have personal experience with that though, so YMMV