It seems like the official MongoDB C# driver is not supported in SilverLight. I want to use MongoDB on the server side and communicate the data via WCF to the silverlight client.
The problem is the Id property in my POCO – Since I can’t import a non-silverlight project into the silverlight – I can’t use [BsonId] or ObjectId in my POCO which should be used by both the server and the client.
I’ve seen questions here on SO about having the Id member as string, but represented as ObjectId in the DB, but I haven’t seen solutions.
What’s the best way to have
public string Id { get; set; }
in my class, but still enjoy the benefits of ObjectId on the server-side of things?
I’ve seen this page, I tried using SetIdMember and MapIdProperty, the _id was null on the inserted documents.
Checkout the documentation here for representation options: http://www.mongodb.org/display/DOCS/CSharp+Driver+Serialization+Tutorial#CSharpDriverSerializationTutorial-RepresentationSerializationOptions
Alternatively, you could use a Guid in both your code and in the database and not need to do mental translations when querying.