Navigation

MongoDB C#/.NET Driver

Introduction

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

Installation

NuGet is the simplest way to get the driver. MongoDB.Driver should be used for all new projects.

For more information, see Installation.

Connect to MongoDB Atlas

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.

Compatibility

MongoDB Compatibility

The following compatibility table specifies the recommended version(s) of the MongoDB C#/.NET driver for use with a specific version of MongoDB.

The first column lists the driver version(s).

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

The driver does not support older versions of MongoDB.

Language Compatibility

The following compatibility table specifies the recommended version(s) of the MongoDB C#/.NET driver for use with a specific version of .NET.

The first column lists the driver version(s).

Driver Version .NET 3.5 .NET 4.0 .NET 4.5 .NET 4.6 .NET 4.7 .NET 4.8 .NET Core 1.0 .NET Core 1.1 .NET Core 2.0 .NET Core 2.1 .NET Core 2.2
Version 2.9    
Version 2.8    
Version 2.7    
Version 2.6    
Version 2.5    
Version 2.4    
Version 2.3    
Version 2.2              
Version 2.0              
Version 1.11          
Version 1.10          

How to get help