按照 MongoDB 官方的教程,使用 Nuget 是最简便的获取 MongoDB driver 的方式。NuGet 是 .NET 的一个包管理器。
高于 2017 的 Visual Studio 自带 NuGet。在 Visual Studio 的搜索框里面搜索 NuGet 就可以搜到。在 NuGet 里面搜索 MongoDB 可以搜到五个包:
MongoDB.Driver
: The new driver. It is mostly free of any legacy code and should be used for all new projects. More documentation can be found in the reference guide.MongoDB.Driver.Core
: The core of the driver and a dependency of MongoDB.Driver. You will probably not use this package directly. More documentation can be found in the reference guide.MongoDB.Driver.GridFS
: The GridFS package. More documentation can be found in the reference guide.MongoDB.Bson
: The BSON layer. It is a dependency of MongoDB.Driver.Core. It may be used by itself. More documentation can be found in the reference guide.mongocsharpdriver
: The compatibility layer for those upgrading from our 1.x series. This should not be used for new projects. More information can be found in the 1.x documentation;
基本上直接安装 MongoDB.Driver
。点击下载即可。