MongoDB.Driver
3.1.0
Prefix Reserved
dotnet add package MongoDB.Driver --version 3.1.0
NuGet\Install-Package MongoDB.Driver -Version 3.1.0
<PackageReference Include="MongoDB.Driver" Version="3.1.0" />
paket add MongoDB.Driver --version 3.1.0
#r "nuget: MongoDB.Driver, 3.1.0"
// Install MongoDB.Driver as a Cake Addin #addin nuget:?package=MongoDB.Driver&version=3.1.0 // Install MongoDB.Driver as a Cake Tool #tool nuget:?package=MongoDB.Driver&version=3.1.0
MongoDB C# Driver
You can get the latest stable release from the official Nuget.org feed or from our github releases page.
Getting Started
Untyped Documents
using MongoDB.Bson;
using MongoDB.Driver;
var client = new MongoClient("mongodb://localhost:27017");
var database = client.GetDatabase("foo");
var collection = database.GetCollection<BsonDocument>("bar");
await collection.InsertOneAsync(new BsonDocument("Name", "Jack"));
var list = await collection.Find(new BsonDocument("Name", "Jack"))
.ToListAsync();
foreach(var document in list)
{
Console.WriteLine(document["Name"]);
}
Typed Documents
using MongoDB.Bson;
using MongoDB.Driver;
public class Person
{
public ObjectId Id { get; set; }
public string Name { get; set; }
}
var client = new MongoClient("mongodb://localhost:27017");
var database = client.GetDatabase("foo");
var collection = database.GetCollection<Person>("bar");
await collection.InsertOneAsync(new Person { Name = "Jack" });
var list = await collection.Find(x => x.Name == "Jack")
.ToListAsync();
foreach(var person in list)
{
Console.WriteLine(person.Name);
}
Documentation
Questions/Bug Reports
If you’ve identified a security vulnerability in a driver or any other MongoDB project, please report it according to the instructions here.
Contributing
Please see our guidelines for contributing to the driver.
Thank you to everyone who has contributed to this project.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
.NET Framework | net472 is compatible. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.7.2
- DnsClient (>= 1.6.1)
- Microsoft.Extensions.Logging.Abstractions (>= 2.0.0)
- MongoDB.Bson (>= 3.1.0)
- SharpCompress (>= 0.30.1)
- Snappier (>= 1.0.0)
- System.Buffers (>= 4.5.1)
- System.Net.Http (>= 4.3.4)
- System.Runtime.InteropServices.RuntimeInformation (>= 4.3.0)
- ZstdSharp.Port (>= 0.7.3)
-
.NETStandard 2.1
- DnsClient (>= 1.6.1)
- Microsoft.Extensions.Logging.Abstractions (>= 2.0.0)
- MongoDB.Bson (>= 3.1.0)
- SharpCompress (>= 0.30.1)
- Snappier (>= 1.0.0)
- System.Buffers (>= 4.5.1)
- ZstdSharp.Port (>= 0.7.3)
-
net6.0
- DnsClient (>= 1.6.1)
- Microsoft.Extensions.Logging.Abstractions (>= 2.0.0)
- MongoDB.Bson (>= 3.1.0)
- SharpCompress (>= 0.30.1)
- Snappier (>= 1.0.0)
- System.Buffers (>= 4.5.1)
- ZstdSharp.Port (>= 0.7.3)
NuGet packages (2.7K)
Showing the top 5 NuGet packages that depend on MongoDB.Driver:
Package | Downloads |
---|---|
AspNetCore.HealthChecks.MongoDb
HealthChecks.MongoDb is the health check package for MongoDb. |
|
MongoDB.Driver.GridFS
GridFS Component of the Official MongoDB .NET Driver. |
|
mongocsharpdriver
This package contains the legacy driver. The new driver's package name is MongoDB.Driver |
|
Mongo2Go
Mongo2Go is a managed wrapper around MongoDB binaries. It targets .NET Framework 4.7.2 and .NET Standard 2.1. This Nuget package contains the executables of mongod, mongoimport and mongoexport v4.4.4 for Windows, Linux and macOS. Mongo2Go has two use cases: 1. Providing multiple, temporary and isolated MongoDB databases for integration tests 2. Providing a quick to set up MongoDB database for a local developer environment |
|
MongoDB.Driver.Core.Extensions.DiagnosticSources
Package Description |
GitHub repositories (194)
Showing the top 5 popular GitHub repositories that depend on MongoDB.Driver:
Repository | Stars |
---|---|
microsoft/semantic-kernel
Integrate cutting-edge LLM technology quickly and easily into your apps
|
|
abpframework/abp
Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.
|
|
dotnet/AspNetCore.Docs
Documentation for ASP.NET Core
|
|
MassTransit/MassTransit
Distributed Application Framework for .NET
|
|
dotnetcore/CAP
Distributed transaction solution in micro-service base on eventually consistency, also an eventbus with Outbox pattern
|
Version | Downloads | Last updated | |
---|---|---|---|
3.1.0 | 85,008 | 12/5/2024 | |
3.0.0 | 817,038 | 10/16/2024 | |
2.30.0 | 619,404 | 10/16/2024 | |
2.29.0 | 1,010,439 | 9/18/2024 | |
2.28.0 | 3,664,575 | 7/23/2024 | |
2.27.0 | 1,963,683 | 6/28/2024 | |
2.26.0 | 901,520 | 6/12/2024 | |
2.25.0 | 3,845,730 | 4/12/2024 | |
2.24.0 | 3,355,336 | 2/21/2024 | |
2.23.2 | 126,562 | 2/20/2024 | |
2.23.1 | 4,879,974 | 12/15/2023 | |
2.23.0 | 512,820 | 12/11/2023 | |
2.22.0 | 6,567,964 | 10/9/2023 | |
2.21.0 | 4,254,248 | 8/10/2023 | |
2.20.0 | 4,846,117 | 6/21/2023 | |
2.19.2 | 2,716,730 | 5/25/2023 | |
2.19.1 | 6,615,913 | 3/27/2023 | |
2.19.0 | 7,561,003 | 1/27/2023 | |
2.18.0 | 8,946,462 | 10/14/2022 | |
2.17.1 | 9,883,391 | 7/30/2022 | |
2.17.0 | 1,196,662 | 7/18/2022 | |
2.16.1 | 2,160,236 | 6/21/2022 | |
2.16.0 | 1,274,713 | 6/7/2022 | |
2.15.1 | 3,734,622 | 5/4/2022 | |
2.15.0 | 4,471,017 | 3/9/2022 | |
2.14.1 | 12,627,320 | 12/3/2021 | |
2.14.0 | 1,366,661 | 11/24/2021 | |
2.14.0-beta1 | 56,408 | 10/15/2021 | |
2.13.3 | 1,067,422 | 11/23/2021 | |
2.13.2 | 8,460,224 | 10/6/2021 | |
2.13.1 | 6,128,568 | 8/4/2021 | |
2.13.0 | 1,562,920 | 7/13/2021 | |
2.13.0-beta1 | 60,956 | 3/31/2021 | |
2.12.5 | 101,731 | 11/20/2021 | |
2.12.4 | 2,813,177 | 6/4/2021 | |
2.12.3 | 2,444,189 | 5/4/2021 | |
2.12.2 | 2,353,386 | 4/7/2021 | |
2.12.1 | 1,328,361 | 3/23/2021 | |
2.12.0 | 4,626,469 | 3/3/2021 | |
2.12.0-beta1 | 129,374 | 11/6/2020 | |
2.11.6 | 9,208,849 | 1/20/2021 | |
2.11.5 | 3,585,099 | 12/2/2020 | |
2.11.4 | 2,254,926 | 11/4/2020 | |
2.11.3 | 2,816,812 | 10/15/2020 | |
2.11.2 | 6,294,564 | 9/10/2020 | |
2.11.1 | 1,148,841 | 8/25/2020 | |
2.11.0 | 2,014,462 | 7/30/2020 | |
2.11.0-beta2 | 25,508 | 6/10/2020 | |
2.11.0-beta1 | 56,429 | 4/10/2020 | |
2.10.4 | 8,598,782 | 5/5/2020 | |
2.10.3 | 1,859,060 | 4/7/2020 | |
2.10.2 | 5,602,610 | 2/14/2020 | |
2.10.1 | 3,162,664 | 1/15/2020 | |
2.10.0 | 6,502,347 | 12/10/2019 | |
2.10.0-beta1 | 46,065 | 10/2/2019 | |
2.9.3 | 3,432,550 | 11/8/2019 | |
2.9.2 | 3,938,873 | 9/30/2019 | |
2.9.1 | 7,094,400 | 8/21/2019 | |
2.9.0 | 343,572 | 8/15/2019 | |
2.9.0-beta2 | 40,273 | 6/17/2019 | |
2.9.0-beta1 | 50,668 | 3/13/2019 | |
2.8.1 | 6,659,287 | 5/15/2019 | |
2.8.0 | 4,756,100 | 3/13/2019 | |
2.7.3 | 2,700,123 | 1/24/2019 | |
2.7.2 | 4,625,592 | 11/10/2018 | |
2.7.1 | 48,460 | 11/8/2018 | |
2.7.0 | 6,436,260 | 6/27/2018 | |
2.7.0-beta0001 | 35,389 | 4/22/2018 | |
2.6.1 | 1,318,607 | 5/17/2018 | |
2.6.0 | 750,364 | 4/24/2018 | |
2.5.1 | 711,203 | 4/19/2018 | |
2.5.0 | 3,388,345 | 12/12/2017 | |
2.4.4 | 3,504,854 | 6/8/2017 | |
2.4.3 | 1,279,204 | 3/9/2017 | |
2.4.2 | 403,129 | 2/2/2017 | |
2.4.1 | 192,992 | 1/4/2017 | |
2.4.0 | 643,632 | 11/29/2016 | |
2.4.0-beta1 | 19,609 | 10/5/2016 | |
2.3.0 | 4,783,683 | 9/23/2016 | |
2.3.0-rc1 | 87,379 | 8/29/2016 | |
2.3.0-beta1 | 11,591 | 8/3/2016 | |
2.2.4 | 859,634 | 5/18/2016 | |
2.2.3 | 537,411 | 2/2/2016 | |
2.2.2 | 60,506 | 1/15/2016 | |
2.2.1 | 24,590 | 1/8/2016 | |
2.2.0 | 152,852 | 12/7/2015 | |
2.2.0-rc0 | 4,892 | 11/18/2015 | |
2.1.1 | 179,755 | 11/11/2015 | |
2.1.0 | 95,720 | 10/19/2015 | |
2.1.0-rc1 | 8,837 | 10/7/2015 | |
2.1.0-rc0 | 6,546 | 9/17/2015 | |
2.0.2 | 62,452 | 11/11/2015 | |
2.0.1 | 371,650 | 6/8/2015 | |
2.0.0 | 406,502 | 4/2/2015 | |
2.0.0-rc0 | 16,701 | 3/17/2015 | |
2.0.0-beta4 | 3,244 | 3/9/2015 | |
2.0.0-beta3 | 2,824 | 3/5/2015 | |
2.0.0-beta2 | 3,973 | 2/4/2015 | |
2.0.0-beta1 | 4,024 | 1/16/2015 |