python ruby-programming-language Smalltalk Vue.js Knockoutjs TypeScript JavaScript, OOPs JavaScript Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 4 Angular 2 AngularJs 1.x NodeJs Perl Programming R Programming RequireJs Rust Programming Backbonejs closure programming language go-programming-language kotlin-programming-language
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!!

Hi there! Welcome to my blog. My name is Anil Singh. I'm a author of this blog. For more detail about me, kindly refer to this link..
My Blogs - and
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like Powered by Blogger.
ASK Questions