I have the following entity with custom ID field:
public class User : IEntity {
public string Id { get; set; }
}
if (!BsonClassMap.IsClassMapRegistered(typeof(User))) {
BsonClassMap.RegisterClassMap<User>(map => map.AutoMap());
}
It works pretty good, when I add new record to collection, ID value is assigned.
However, when I'm trying to index any other field within this collection:
UserCollection.EnsureIndex(IndexKeys<User>.Ascending(p => p.Email),IndexOptions.SetUnique(true));
Id mapping becames broken, ID field value is null after insert and in collection I see default '_id' field generated (insead of my 'ID'). Any ideas what's the problem? (I'm using driver 1.8.3.9, mongo win32 2.4.5, NET 4.5). Thanks.