The Current State of MongoDB and C#
As a C# developer, I am often disappointed with the lack of drivers and connectors to cool services like MongoDB. All the cool languages (and Java) get all the love but C# is often an afterthought.
Luckily for me, there are some kickass developers in the C# community who also share my frustration and as such, they have begun building their own C# MongoDB drivers.
I keep stumbling across more and more C# related MongoDB projects, so I figured I would write up a list and some short descriptions of these projects.
List of C# MongoDB Projects
Each of these projects are still rather new, so expect some features to be missing or not fully functional. A couple of them are usable in your projects today while the rest are still under heavy development
mongodb-csharp
Originally written by Sam Corder (@SamCorder) with help from a handful of contributers, this is the most complete driver of the bunch. It has been evolving quickly and Sam & team are very quick to resolve any bugs that may arise.
I am using this driver in 2 projects that I am working on and so far things have been great. It even includes GridFS suport.
From the project description:
Current Features
- Connect to a server.
- Query
- Insert
- Update
- Delete
- All BSON types supported
- DBRef support
- Isolation and conversion between BSON types and native .net types.
- Database, Collection and Cursor objects.
- Index handling routines (List, Create, Drop)
- Count
- Roughly 80% unit test coverage. This can and will be improved on.
- Paired connections
- Authentication (Does not reauthorize on auto reconnect yet).
- Database Commands
- Basic Linq support
- GridFS support
- Map Reduce helpers.
- hint, explain, $where
They are currently working on connection management features (auto reconnect, connection pooling, etc).
Get involved or check out the code at their mongodb-csharp project page on Github.
mongodb-net
Written by the unnamed developer at DevFuel.com, the mongo-net project aims to be a C# port of the 10Gen\MongoDB official Java driver. While a lot of work has been done and a load of code written, it is currently unusable. Over the past couple of weeks a significant amount of progress has been made and functionality is beginning to work but it seems that a functional state is months away.
I would keep an eye on this project, though, as having an API compatible with the official Java driver has its benefits.
Get involved or check out the code at their mongodb-net project page on Google Code.
MongoDB.Emitter
Andrew Rondeau’s MongoDB.Emitter is a pretty cool project that provides a strongly-typed Document mapper for C#. It works in conjunction with Sam Corder’s mongodb-csharp driver allowing the programmer to define strongly typed interfaces and properties.
I have not tried this yet, but this will be on my list of things to check out.
Get involved or check out the code at their MongoDB.Emitter project page on bitbucket.
CSMongo
Hugo Bonacci (@hugoware) has been working on a driver of his own called CSMongo. CSMongo doesnt support everything that mongodb-csharp does but it does have some interesting features, such as the approach to creating Mongo Documents. Their approach definitely has a more dynamic feel to it which fites nicely in the unstructured MongoDB world.
I am looking forward to the next version which should have more features including support for Hugo’s own jLinq.
Code doesn’t appear to be released yet but you can follow his progress at his blog, Hugoware.
simple-mongodb
Simple-mongdb is another project without public source that is being worked on by Daniel Wertheim (@danielwertheim). I am not sure if it is even being actively developed but it too has some nice ideas. The goal of this project is to keep the driver JSON-centric and should be compatible with awesome Newtonsoft’s JSON.net library.
They have a few examples of the proposed API but no code has been released to make said examples work. This is another one to keep an eye on in the meantime.
Check out the simple-mongodb project page on Google Code.
DocumentConverter
This is a small class I wrote that works with mongodb-csharp. Its name will likely change at some point if and when it gets packaged up and put on source control. It exposes two functions that will allow any C# class to convert to and from a MongoDB Document object automatically. It makes my life a lot easier and it uses System.Reflection to do this.
Read more about DocumentConverter on this blog post.
Conclusion
Well it looks like there is a significant amount of interest in MongoDB from the C# community which is great news because it looks like MongoDB is going to continue to thrive and grow. My bet is that Sam Corder’s driver will be the most common C# driver, simply because it is so far ahead of the rest but time will tell. Extensions of Sam’s project, such as MongoDB.Emitter, are equally as cool as the drivers they are built on.
Thanks toeveryone who has contributed to these drivers. Each of them have some great concepts and I hope that one day we will have a driver that supports all these great ideas and features.
If there are any more projects that I have missed – let me know in the comments!
|
|
|
|
|
![]() |












February 23rd, 2010 at 3:34 pm
Hi Bryan,
http://twitter.com/atheken/statuses/9452237606
The group mentioned here is also worth looking at. All top notch .Net developers.
Sebastien
February 23rd, 2010 at 3:46 pm
Thanks Sebastien – nice list and an exciting announcement too. I look forward to seeing what those guys come up with.
March 4th, 2010 at 8:14 pm
Hi
My Simple-MongoDb is out in a very early release. Since I’m relying on Json.Net for the serializatio of Bson I also get complete Json support and therfore don’t need a specific document class that is key-value based. I also don’t need a proxy or any mappers. It just works and gives support for anonymous types as well as static types and of course json-strings.
//Daniel
March 5th, 2010 at 2:40 pm
Hi,
First of all, thanks for the overview and mention.
Secondly, a brief update:
I have now got mongodb-net doing simple round-tripping of data. While that doesn’t necessarily make it “usable” yet, I am definitely making progress. It would be helpful (at this stage) to get some design feedback and some use cases that people want to be supported.
To contact me (or to get finer-grained updates), I am @devfuel on twitter, and I post updates to the #mongodbnet hashtag.
Regards,
ee
April 11th, 2010 at 12:14 pm
[...] Somente para a framework .NET existem 6 drivers/ferramentas, segundo Bryan Migliorisi em um artigo em seu blog e, dentre esses, o mongodb-csharp, desenvolvido por uma trupe liderada por Sam Corder, é o mais [...]
April 16th, 2010 at 5:55 am
why not mongoadmin?
June 30th, 2010 at 5:00 pm
I’ve just been to a presentation on NoRM. It strongly typed and seens very flexible, also with nice features like linq to mongo. It can be found at: http://github.com/atheken/NoRM
August 11th, 2010 at 1:32 pm
really nice topic. keep posting similar