Are mongodb ids unique ?

Why use MongoDB in MVC.Net?

“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.”

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

Example Source code for MongoDb with MVC 5 as,

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 ="",
                    CretaeDate =DateTime.Now

            //DROP COLLECTION
            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,

I hope you are enjoying with this post! Please share with you friends. Thank you!!

Hey! I'm Anil Singh. I author this blog. I'm Active Blogger, Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
My Blogs - and
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like
Post a Comment Powered by Blogger.
ASK Questions