Navigation

MongoDB C#/.NET Driver

The official MongoDB C#/.NET Driver provides asynchronous interaction with MongoDB.

Banner for the M220N MongoDB University Course
M220N: MongoDB for .NET Developers
Learn the essentials of C# & ASP.NET application development with MongoDB.

NuGet is the simplest way to get the driver. Use MongoDB.Driver for all new projects.

For more information, see Installation.

To connect to a MongoDB Atlas cluster, use the Atlas connection string for your cluster:

using MongoDB.Bson;
using MongoDB.Driver;
// ...
var client = new MongoClient(
"mongodb+srv://<username>:<password>@<cluster-address>/test?w=majority"
);
var database = client.GetDatabase("test");

See Connecting for more information.

C#/.NET Driver Version
MongoDB 4.4
MongoDB 4.2
MongoDB 4.0
MongoDB 3.6
MongoDB 3.4
MongoDB 3.2
MongoDB 3.0
MongoDB 2.6
2.12
2.11
2.10
2.9
2.8
2.7
2.6
2.5
2.4
2.3
2.2
2.0
1.11
1.10

The driver does not support older versions of MongoDB.

C#/.NET Driver Version
.NET 5 [1]
.NET Core 3.1
.NET Core 3.0
.NET Core 2.2
.NET Core 2.1
.NET Core 2.0
.NET Core 1.1
.NET Core 1.0
.NET 4.8
.NET 4.7
.NET 4.6
.NET 4.5
2.12
2.11
2.10
2.9
2.8
2.7
2.6
2.5
2.4
2.3
2.2
2.0

Versions 1.10 and 1.11 of the driver are compatible with .NET 3.5 through 4.8 only.

[1] When using .NET 5, you can't connect to Atlas clusters running MongoDB 4.0 due to a certificate issue.

For more information on how to read the compatibility tables, see our guide on MongoDB Compatibility Tables.

Give Feedback