UmbracoExternalStorageWithMongoDB 17.0.4

dotnet add package UmbracoExternalStorageWithMongoDB --version 17.0.4
                    
NuGet\Install-Package UmbracoExternalStorageWithMongoDB -Version 17.0.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="UmbracoExternalStorageWithMongoDB" Version="17.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="UmbracoExternalStorageWithMongoDB" Version="17.0.4" />
                    
Directory.Packages.props
<PackageReference Include="UmbracoExternalStorageWithMongoDB" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add UmbracoExternalStorageWithMongoDB --version 17.0.4
                    
#r "nuget: UmbracoExternalStorageWithMongoDB, 17.0.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package UmbracoExternalStorageWithMongoDB@17.0.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=UmbracoExternalStorageWithMongoDB&version=17.0.4
                    
Install as a Cake Addin
#tool nuget:?package=UmbracoExternalStorageWithMongoDB&version=17.0.4
                    
Install as a Cake Tool

NuGet

What does this package do?

This package allows you to store your custom data in a NoSQL MongoDB database. Unlike most NoSQL databases, a MongoDB server can be installed on almost any platform, your laptop or on a Cloud service like AWS, GCP or Azure. It avoids vendor lock-in into any specific hosting platform.

It is built on MongoDbService and registers it with Umbraco automatically, so you can inject MongoService anywhere in your site.

Requirements

  • Umbraco 17
  • .NET 10

Setup procedure

  1. Set up a MongoDB server either locally on your laptop or you can use the MongoDB free hosting plan to create an instance on AWS, GCP or Azure.
  2. Update appsettings.json file with the connection string to the above database
{
	"MongoDbSettings": {
		"ConnectionString": "<mandatory> mongodb+srv://<user>:<password>@<cluster>.mongodb.net/?retryWrites=true&w=majority",
		"DatabaseName": "<optional, defaults to Untitled-MongoDbService>",
		"ConnectionRecordRetentionDays": 30
	}
}

Keep the connection string out of source control: for local development use user secrets (dotnet user-secrets set "MongoDbSettings:ConnectionString" "<connection string>"), and in hosted environments set the MongoDbSettings__ConnectionString environment variable. If ConnectionString is missing, an ArgumentException is thrown the first time MongoService is resolved. 3. Install this package

dotnet add package UmbracoExternalStorageWithMongoDB

Sample code

using MongoDB.Driver;
using MongoDbService;

public sealed class VehicleHandler
{
	private readonly IMongoCollection<Vehicle> _vehicleCollection;

	public VehicleHandler(MongoService mongoService)
	{
		_vehicleCollection = mongoService.Database.GetCollection<Vehicle>("YourCollectionName");
	}
}

Register your own classes with Umbraco, for example in a composer:

using Microsoft.Extensions.DependencyInjection;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.DependencyInjection;

public sealed class VehicleComposer : IComposer
{
	public void Compose(IUmbracoBuilder builder) => builder.Services.AddSingleton<VehicleHandler>();
}

For more examples on how to Insert, Modify your data, check the MongoDbService documentation and the MongoDB official documentation: https://www.mongodb.com/docs/drivers/csharp/current/quick-reference/

Upgrading from version 13

Version 17 is a breaking change:

  • The configuration section is renamed from MongoDbCredentials to MongoDbSettings, and the database name now comes from MongoDbSettings:DatabaseName.
  • CertificateFilePathWithName and CertificatePassword are no longer supported.
  • The static MongoDBClientConnection.GetDatabase("...") is replaced by injecting MongoService and using mongoService.Database.
  • MongoDbService writes a ConnectionRecord document each time the site connects. These are removed after ConnectionRecordRetentionDays (default 30).

Want to sponsor?

This is a free package, but if you want to sponsor my open source work, here is my GitHub profile

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
17.0.4 47 10/2/2026
13.0.0 590 12/16/2023
12.0.0 739 7/2/2023