首页 > 代码库 > mongodb .net core 调用

mongodb .net core 调用

MongoClient _client;
IMongoDatabase _db;


MongoCredential credential = MongoCredential.CreateMongoCRCredential("pethome", "username", "pwd"); MongoClientSettings settings = new MongoClientSettings { Credentials = new List<MongoCredential>() {credential}, Server = new MongoServerAddress("ip") }; _client = new MongoClient(settings); _db = _client.GetDatabase("pethome");

 

mongodb .net core 调用