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. 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 VersionMongoDB 4.2MongoDB 4.0MongoDB 3.6MongoDB 3.4MongoDB 3.2MongoDB 3.0MongoDB 2.6
    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 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.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

    How to get help