RepositoryKit.MongoDB 9.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package RepositoryKit.MongoDB --version 9.0.2
                    
NuGet\Install-Package RepositoryKit.MongoDB -Version 9.0.2
                    
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="RepositoryKit.MongoDB" Version="9.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RepositoryKit.MongoDB" Version="9.0.2" />
                    
Directory.Packages.props
<PackageReference Include="RepositoryKit.MongoDB" />
                    
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 RepositoryKit.MongoDB --version 9.0.2
                    
#r "nuget: RepositoryKit.MongoDB, 9.0.2"
                    
#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 RepositoryKit.MongoDB@9.0.2
                    
#: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=RepositoryKit.MongoDB&version=9.0.2
                    
Install as a Cake Addin
#tool nuget:?package=RepositoryKit.MongoDB&version=9.0.2
                    
Install as a Cake Tool

<div align="center"> <img src="logo-64x64.png" width="120" alt="RepositoryKit logo" />

RepositoryKit.MongoDB

MongoDB Driver Implementation for RepositoryKit

</div>


📦 Package

Provides a repository implementation using MongoDB.Driver. It supports flexible querying and follows the same interface contract as EF version.


✨ Features

  • MongoRepository<T, TKey> implements all core contracts
  • Async-first design
  • Supports filtering, sorting, and paging
  • Clean integration with MongoDB collections

🧰 Usage

services.Configure<MongoDbOptions>(Configuration.GetSection("MongoDb"));
services.AddSingleton<IMongoClient>(sp =>
{
    var options = sp.GetRequiredService<IOptions<MongoDbOptions>>().Value;
    return new MongoClient(options.ConnectionString);
});
services.AddScoped<IMongoDatabase>(sp =>
{
    var options = sp.GetRequiredService<IOptions<MongoDbOptions>>().Value;
    return sp.GetRequiredService<IMongoClient>().GetDatabase(options.Database);
});

services.AddScoped(typeof(IRepository<,>), typeof(MongoRepository<,>));

🔍 Example

// appsettings.json
"MongoDb": {
  "ConnectionString": "mongodb://localhost:27017",
  "Database": "RepositoryKitDb"
}

// Define your entity
public class Product
{
    public Guid Id { get; set; }
    public string Name { get; set; }
}

// Injected service
private readonly IRepository<Product, Guid> _repo;

public ProductService(IRepository<Product, Guid> repo)
{
    _repo = repo;
}

// Usage
await _repo.AddAsync(new Product { Id = Guid.NewGuid(), Name = "Pen" });

📁 Requirements

  • MongoDB.Driver
  • Microsoft.Extensions.Options

📜 License

MIT © Ataberk Kaya


📎 This package depends on RepositoryKit.Core

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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 (1)

Showing the top 1 NuGet packages that depend on RepositoryKit.MongoDB:

Package Downloads
RepositoryKit

Umbrella package for RepositoryKit - a modular repository pattern infrastructure that supports EF Core, MongoDB and clean LINQ extensions.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
9.0.3 147 6/3/2025
9.0.2 144 6/1/2025

Initial stable version for MongoDB repositories compatible with .NET 9.