DEV Community

Discussion on: Tutorial: MongoDB With C# The Easy Way!

Collapse
 
feddessi profile image
Federico Dessì • Edited

Hi, I've read through your documentation but I can't find what I'm looking for. In the official MongoDB driver you can specify if you want your ID to be a specific field instead of the generic ObjectID, how can I do the same here?

I'll be more specific: In your Wiki you give the example of a Book entity, I would like to specify the _id field to be the ISBN number (for example) instead of auto generating a mongo ObjectID. Is this possible?

Collapse
 
djnitehawk profile image
Dĵ ΝιΓΞΗΛψΚ

with this library it's not possible to change the type of the default id as objectid was chosen to be the best option for >90% of cases. you can however simply add another property to store the ISBN and put an index on it so queries can be written on that instead of querying by the ID. imho it's a small price to pay considering the benefits offered by the library.