Integration of Mongodb with .NET (Visual Studio) - OmIndia

Teach To India

Friday, August 03, 2018

Integration of Mongodb with .NET (Visual Studio)

How To use MongoDB in Visual Studio



First, run Visual Studio and create a project.
download MongoDB c# references from MongoDB Website

http://mongodb.github.io/mongo-csharp-driver

Add MongoDB References to Bin Folder.



Now use these on the aspx.cs page.

using MongoDB.Bson;
using MongoDB.Driver;


Add a key to web.config



   var con = ConfigurationManager.ConnectionStrings[“KeyName"].ConnectionString;
    MongoClient Client_ = new MongoClient(con);
    MongoServer Server_ = Client_.GetServer();
    MongoDatabase md = Server_.GetDatabase(DbName);


No comments:

Post a Comment

Comments

Popular