I have been playing around a bit with MongoDB for the first time of my life. It's really a very nice experience and have a lot of the "just works"-feeling that I have started to get used to from frameworks like NancyFx and Simple.Data.
But when i pushed it to AppHarbor I ran into problems. That all had with me not reading stuff properly…
AppHarbor has a nice feature that replaces stuff in your .config files on deploy. That could be used for setting Production-environment values to your environment configuration. For example changing the connection string for a database.
The add-on for Mongo DB at AppHarbor has a nice article describing this in detail. But I read it quickly and put the connection string in the
It should be added as an
You can then read that value as simple as this:
private readonly MongoCollectionpublic MongoRepository()
var connectionString =
var client = new MongoClient(connectionString);
var server = client.GetServer();
var con = new MongoUrlBuilder(connectionString);
var db = server.GetDatabase(con.DatabaseName);
_collection = db.GetCollection
With that in place … it just works!