MongoDB & ASP.NET MVC: Where to specify database name -
this question has reply here:
mongodb: connecting asp.net mvc application 1 replyi trying run mongodb visual studio asp.net mvc 5 project. question is: how tell visual studio name of database want use?
so far, have next in <appsettings> of web.config:
<add key="dbname" value="db1" /> then, run mongod command start mongodb, , run visual studio debugger. shows me page have written allows me register user, should create entries in database. however, when go mongodb shell running mongo, , type in show dbs, following:
aspnetdb 0.078gb admin (empty) local 0.078gb and there no sign of db1 database specified before.
please can explain how specify name of database want use?
that normal specified in web.config file under connectionstrings like
<add name="mongohq" connectionstring="mongodb://<user>:<pwd>@<host>:<port>/<collection>" /> and using mongodb drivers can connect as
var server = mongoserver.create(connectionstringfromconfig).getdatabase("your_db"); but can find all documentation in mongodb docs
asp.net-mvc mongodb
No comments:
Post a Comment