MongoDB: connecting with ASP.NET MVC application -


I have created an asp.net mvc5 application, and I'm hosting it on IIS 7. Now I would like to start using this MongoDB database with this application. I have been able to run a Mongodabi Windows service, but now what I am doing in the next step.

Like:

i) How do I specify in my ASP? Net MVC application that is the name of the database, and where is that directory stored?

ii) How do I create this database in mangodibi?

My web In the configured file, I have the following lines:

  & lt; Connection best & gt; & Lt; Add name = "Mongo" connection String = "mongodb: // localhost" /> & Lt; / ConnectionStrings & gt;  

and:

   & Lt; Add Key = "MONGOHQ_URL" value = "mongodb: // localhost" /> & Lt; / AppSettings & gt;  

How do I go about creating a database called mydb , as if it is running in the Mongo DB Windows Service?

i) How do I specify in my ASP.NET MVC application, the name of the database Is it stored in the directory where it is?

The directory where it is stored is not specified with your Mongoode example, not your MVC application. When you start your mouthdown instance, you should have something like this:

  mongod.exe --dbpath [where your db is stored]  

To learn more about the mongod.exe parameter, have a look at.
The name of your database is specified in the connection string. This will be something like this:

  mongodb: // localhost / dbName? [Options]  

You can find the full instruction.
Still, I do not know if I'm the only one who detects C # Driver API software. To start a Mongo client (top-level database object), most people will have to go through the most simple way:

  Mongo client client = new monoglant (connot);  

In this way you will never find the database name to get it:

  Mongo url = new mongol (connStr); MongoClient Client = New Mongo Client (URL); Var dbName = url.DatabaseName / retrive Database Name var db = client.GetServer (). GetDatabase (dbName);  

In this way you can store the database name with the connection string. Which I like

ii) How do I create this database in Mongodi?

You can not do this, do it. When you first enter the data in the database, then Mongoode will create a database for you, as well as a collection. However later you may find this useful in some collections.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -