LiteDB: Embedded .NET NoSQL Database

I was recently in the need for a simple NoSQL database that I could use for an app I was creating for a ASP.NET Core Workshop.

What I was really after was something similar to SQLite.   A single package I could pull into my application that did not require any external service and data stored in a single file.

It didn’t take long to find LiteDB.  After using it for my demo application, I had write a quick post about it.  Just to shed some light for anyone in need.  The project is actually really popular on GitHub, so it seems I might just be late to the party about finding out about it.

LiteDB

LiteDB is serverless database delivered in a single DLL (less than 350kb) fully written in .NET C# managed code (compatible with .NET 3.5, 4.x, NETStandard 1.3 and 2.0).

Install via NuGet or just copy DLL to your bin project folder.

Sample

Similar to MongoDB

One thing to note is how the API is similar to the Mongo DB .NET driver.

You also can store files like you can in GridFS.

Use Cases

I would think the use cases would be similar in terms of need for something like SQLite.  Because it supports .NET Standard, I would think Xamarin apps would be an excellent fit.

Again, my application was a small local application, which was also ideal.

Are you using LiteDB? Using something different? I’d love to hear what your using and your workloads which you’re using it in.  Let me know on Twitter or in the comments.

Enjoy this post? Subscribe!

Subscribe to our weekly Newsletter and stay tuned.

.NET Video Tutorials

I’ve started a YouTube channel last year to provide some video content to many of my blog posts.  I’ve never really mentioned it on this blog, which seems crazy.  Primarily these are .NET Video Tutorials as well as recorded talks that I’ve done at various conferences.

Please take a look and subscribe if this is up your alley.  I plan on providing regular content on YouTube as well as continuing to do so on this blog.  Video just seems like a natural extension to provide content that is generally on this blog.

Popular Videos

How to Self Host ASP.NET Web API

Not everyone is able to migrate their applications to ASP.NET Core.  Many are not even aware that you can self-host a WebAPI project with Katana (Owin).  You can, here’s how!

Fat Controller CQRS Diet Series

My series of blog posts have backing tutorials to view.  As well as a talk around the overall concept.

Everyone Love Cake!

One of the first videos I’ve made was getting started with Cake for automating your build process.

Suggestions

I’m always looking for suggestions.  If you have any questions or suggestions for video tutorials or blog posts please let me know on Twitter or in the comments.  Over the years I’ve gotten some create feedback and it’s very appreciated.

 

 

Enjoy this post? Subscribe!

Subscribe to our weekly Newsletter and stay tuned.

 

 

Migrating to SDK csproj

The SDK csproj files introduced with Visual Studio 2017 are a much needed improvement to the project files.    If you are creating a new .NET Core project or a .NET Standard library, either with VIsual Studio 2017 or the .NET CLI via dotnet new, it will generate the new SDK csproj.  What isn’t very clear to many is that you can use the new SDK format with full .NET Framework apps.  So this post will point out a really simple way for migrating to SDK csproj.

SDK Benefits

First, if you are unfamiliar with the new SDK csproj, here are a few of the benefits.

  • Include files using a wildcard as opposed to specifying every single file.
  • Simpler referencing of solution project references.
  • Reference NuGet package as references.  No more packages.config.
  • Define Some AssemblyInfo attributes.
  • NuGet package definition as part of the project file.  No more nuspec.

Old Style

Here’s the older style csproj from a .NET Framework 4.7.1 class library that references another class library.  There is a NuGet Package to Newtonsoft.Json

Migrating to SDK csproj

If you want to do manual conversions, take a look at this post by Nate McMaster.  However, ain’t nobody got time for manual conversions.  Luckily there is a tool that does a lot of the heavy lifting for your.  The CsprojToVs2017 project on Gith=Hub has been working wonders for me.  It either has worked in generating a full conversion or got me most of the way there.

Simply run the exe specifying the csproj file to convert:

.\Project2015To2017.exe YourClassLibrary.csproj

Here is the converted csproj file.  You can see

AssemblyInfo

There are a couple of errors after the conversion.

Since the csproj now contains some assembly info that is also in our existing AssemblyInfo.cs.  Specifically these two:

[assembly: System.Reflection.AssemblyCompanyAttribute("ClassicClassLibrary")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]

We can either remove the appropriate lines from our csproj or from our AssemblyInfo.cs  The choice is yours.

PackageReference and Reference

The conversion looked at our packages.config and created the appropriate <PackageReference ../>.  However, it also created <Reference ../>, which we no longer need.  So we can delete any of those that are actually NuGet Packages.

More

There are a ton of situations such as content files that it was handle appropriately.  If you have many project files that you would like to convert, I suggest giving this tool a shot.  Even if it gets you 80% of the way there and requires a bit of cleanup, I find it well worth it.

Are you converting?

If so, are you doing rewriting the project files manually or using this or a different tool?  I’d love to hear your comments or in Twitter.

 

 

Enjoy this post? Subscribe!

Subscribe to our weekly Newsletter and stay tuned.