1

I am starting a new project and wanting to use appharbor and mongohq. The example for this on appharbor seems invalid since it uses MongoDatabase.Create and that is now obsolete. I was hoping that there was an updated guide or example that users MongoClient, MongoServer, and MongoDatabase as is recommended.

Is there another way to build get an instance of MongoDatabase with the key provided?

Josh
  • 1,058
  • 9
  • 27

1 Answers1

2

You can initialize a MongoDatabase with the connection string injected on AppHarbor like so:

var connectionstring = ConfigurationManager.AppSettings.Get("(MONGOHQ_URL|MONGOLAB_URI)");
var url = new MongoUrl(connectionstring);
var client = new MongoClient(url);
var server = client.GetServer();

var database = server.GetDatabase(url.DatabaseName);

The knowledge base article has been updated to reflect the new C# driver API.

This thread covers the same question.

Community
  • 1
  • 1
runesoerensen
  • 3,234
  • 2
  • 22
  • 21