Dette er ændret, jeg bruger den seneste 1.x-driver (Nuget-pakke <package id="mongocsharpdriver" version="2.0.0" targetFramework="net45" />
) og i stedet for at bruge SetRepresentation
du indstiller serializeren.
public class RegistrationAttempt
{
public string AttemptId { get; set; }
}
BsonClassMap.RegisterClassMap<RegistrationAttempt>(cm =>
{
cm.AutoMap();
cm.MapIdProperty(c => c.AttemptId)
.SetIdGenerator(StringObjectIdGenerator.Instance)
.SetSerializer(new StringSerializer(BsonType.ObjectId));
});