Navigation

    MongoDB C#/.NET Driver

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

    /figures/M220N.png
    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 VersionMongoDB 4.4MongoDB 4.2MongoDB 4.0MongoDB 3.6MongoDB 3.4MongoDB 3.2MongoDB 3.0MongoDB 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.

    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.

    Give Feedback