Blog

Using Mongo DB in .Net

Posted by Venkatesh Kumar Blogs | Databases & DBA Jul 20, 2012
Using an open source database in .NET is not quite popular. In this blog, I am using Mongo DB in .Net. Here I explain the startup program and how we can connect with the Mongo DB in an ASP.NET application using .NET.

Here I am not going to explain about Mongo DB, but  just try to use Mongo DB in .Net.

By default, MongoDB wants to store data in the default file system path, c:\data\db.but this is configurable with a text file passed by name on the command line via --config.




 If you got the below error.  Just run the below mentioned command.

Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84

Command:  mongod --dbpath "c://data/db"

Once configured the Mongo DB, we will install C# driver or we can use the NuGet package.

 http://www.nuget.org/List/Packages/mongocsharpdriver

After install the driver, add reference dll's as mentioned below.


MongoDB.Bson

MongoDB.Driver

 

We will go through the sample application to use Mongo DB in .Net:

Just like SQL Server we need to create connection instance to the Mongo DB server.

Once the Db will be created we can able to go and check the db folder “\data\db” and the final thing is we can able to  add and query the data like sql.

Check the SQL to Mongo Mapping chart:

We execute the select query (.Find), get the data.

post comment
     

Thank you, can you give me the one complete simple example using MongoDB with ASP.NET???

Posted by anil babu Apr 29, 2013

Thanks Mahesh and will upload the contents in future posts.

Posted by Venkatesh Kumar Jul 20, 2012

Good start. You can direct upload code sample and images here that will make your blog better readable.

Posted by Mahesh Chand Jul 20, 2012
COMMENT USING
PREMIUM SPONSORS
Over-C is a holistic consortium of communications and technology specialists. We build, deploy and market both business as well as consumer products and solutions.
Join a Chapter
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Join a Chapter