“The MongoDB is now most popular cross platform NoSQL open source database management system. The MongoDB is written using the C++ language and developed by 10gen but now it's called MongoDB Inc.”
Stayed Informed - 117 Recommend MongoDB Tutorial for Beginners
Now, coming back to the point, “Why use MongoDB in MVC?”. The main reason is to use MongoDB with ASP.Net MVC are,
1. It is so Faster Development.
2. It is so Minimal Migrations.
3. It is much Easier Collaborations.
4. It is so Maintainable Design.
5. It is much Rich Behaviours.
6. Scalability.
7. GridFS
using System; using System.Web.Mvc; using MongoDB.Driver; using MongoDB.Bson; namespace MongoDemoApp.Controllers { public class HomeController : Controller { public ActionResult Index() { MongoClient client = new MongoClient(); //GET MONGO SERVER. var server = client.GetServer(); ////GET MONGO DATABASE. var db = server.GetDatabase("MongoDemo"); ////GET MONGO COLLECTION. var collection = db.GetCollection("Users"); ////ADD COLLECTION ROWS. collection.Save(new Users { name ="Anil Singh", site ="code-sample.com", CretaeDate =DateTime.Now }); //DROP COLLECTION //collection.Drop(); return View(collection); } public class Users { public ObjectId id { get; set; } public string name { get; set; } public string site { get; set; } public DateTime CretaeDate { get; set; } } } }
Result as,
Stayed Informed - 71 MongoDB Interview Questions & Answers