MongoDB C#/.NET Driver¶
Introduction¶
The official MongoDB C#/.NET Driver provides asynchronous interaction with MongoDB.
Take the free online course taught by MongoDB¶
![]() |
|
Installation¶
NuGet
is the simplest way to get the driver. Use
MongoDB.Driver 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¶
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 |
---|---|---|---|---|---|---|---|---|
Version 2.11 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Version 2.10 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |
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¶
Driver Version | .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 | .NET Core 3.0 | .NET Core 3.1 |
---|---|---|---|---|---|---|---|---|---|---|---|
Version 2.11 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Version 2.10 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
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 | ✓ | ✓ | ✓ | ✓ |
Versions 1.10 and 1.11 of the driver are compatible with .NET 3.5 through 4.8 only.
For more information on how to read the compatibility tables, see our guide on MongoDB Compatibility Tables.
How to get help¶
- Ask questions on our MongoDB Community Forums.
- Visit our Support Channels.
- See the project JIRA to raise issues or request features.
Give Feedback