-1

I am trying to run MongoDB with my Visual Studio ASP.NET MVC 5 project. My question is: how do I tell Visual Studio the name of the database that I want to use?

So far, I have the following in the <appSettings> of Web.config:

<add key="DbName" value="db1" />

Then, I run the mongod command to start MongoDB, and then run the Visual Studio debugger. It shows me a page I have written which allows me to register a user, which should create some entries in the database. However, when I go to the MongoDB shell by running mongo, and type in show dbs, I get the following:

ASPNETDB 0.078GB
admin (empty)
local 0.078GB

And there is no sign of the db1 database I specified before.

Please can someone explain where how I specify the name of the database I want to use?

1
  • Mongo does not have Tables, it has Collections! Commented Jun 18, 2014 at 12:28

1 Answer 1

0

that is normal specified in the web.config file under connectionStrings like

<add name="MongoHQ"
     connectionString="mongodb://<user>:<pwd>@<host>:<port>/<collection>" />

and then using MongoDB drivers you can easily connect as

var server = MongoServer.Create(connectionStringFromConfig).GetDatabase("your_db");

but you can find all documentation in mongoDB docs

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.