如何在Mac OS上通过终端安装Mongodb C#驱动程序

时间:2018-04-10 04:36:49

标签: c# mongodb terminal nuget-package

我想从客户端在服务器上安装Mongodb C# driver。因此,我必须使用Terminal进行安装。我试图手动下载.nupkg文件,但我无法安装它。

谁能告诉我怎么做?

更新

现在我使用nuget install mongoDB.Drivernuget install mongocsharpdriver

我得到了

Successfully installed 'mongocsharpdriver 2.5.0' to /Users/my/project/path

但是当我尝试使用mcs Program.cs

我仍然有这个错误

Program.cs(3,7): error CS0246: The type or namespace name 'MongoDB' could not be found. Are you missing an assembly reference?
Program.cs(4,7): error CS0246: The type or namespace name 'MongoDB' could not be found. Are you missing an assembly reference?
Program.cs(5,7): error CS0246: The type or namespace name 'MongoDB' could not be found. Are you missing an assembly reference?
Program.cs(54,16): error CS0246: The type or namespace name 'ObjectId' could not be found. Are you missing an assembly reference?

任何人都可以帮我解决这个问题吗? 我不知道为什么找不到'MongoDB'。

我的program.cs就像这样

using System;
using System.IO;
using MongoDB.Bson;
using MongoDB.Driver;
namespace testMongo
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var connectionString = "mongodb://localhost";
            var client = new MongoClient(connectionString);
            var database = client.GetDatabase("test");
            var collection = database.GetCollection<Entity>("uesr");
        }
    }
}

0 个答案:

没有答案