MongoDB website
https://www.mongodb.com/
MongoDB default installation path (Windows x64 platform)
C:\Program Files\mongodb\server\3.4\bin
MONGODB environment variable Configuration
Start MongoDB Service
> Mongod-dbpath D:\mongodb
> MONGO
Visual Studio References MongoDB
Pm> Install-package Mongodb.driver
C # operations See
https://docs.mongodb.com/ecosystem/drivers/csharp/
String url = "mongodb://127.0.0.1:27017"; var client = new Mongoclient (URL); var db = client. Getdatabase ("blog");//Get the database and create a var collection = db If it does not exist. Getcollection<post> ("Post"); Increment//for (int i = 1; i < 10000; i++) {//Post post = new post ()//{//Id = i,//Author = "Author" + I,//Createtime = DateTime.Now,//Issue = False,//Title = "ARTICLE" + I,//Details = Guid.new Guid (). ToString (),///Comments = new list<string> () {"Comment" + i}//}; Collection. Insertone (POST); }//Check//Console.WriteLine (collection. Countdocuments (c = 1 = = 1)); var P5 = collection. Find (p = = P.id = 5). First (); Console.WriteLine ("{0} published {2}" in {1}, P5. Author, P5. Createtime, P5. Title); Delete//collection. Findoneanddelete<post> (p = p.id = = 6); var P6 = collection. Find<post> (p = p.id = = 6). FirstOrDefault (); Change//var filter = Builders<post>. Filter.eq ("Id", 7); var update = builders<post>. Update.set ("Title", "Summer"); Collection. Findoneandupdate<post> (filter, update); var P7 = collection. Find (f = f.id = = 7). FirstOrDefault (); Console.WriteLine ("{0} published {2}" in {1}, P7. Author, P7. Createtime, P7. Title);
Configuring MongoDB Services
Create the profile mongod.cfg in the MongoDB installation directory, and then add the output path of the service log to the configuration file (there is no mandatory requirement for the path)
systemLog: destination: file path: D:\mongodb\logs\mongodb.logstorage: dbPath: D:\mongodb\data
Open Cmd.exe by admin
>mongod--config "D:\mongoDB\mongod.cfg"--install--servicename "MongoDB"
Getting Started with C # and MongoDB