Primary keys can be of type char, short, int, long, string, or MongoDB.Bson.ObjectId. Once you assign a property as a primary key, you cannot change it after an object of that type is added to a realm.
But, I get the following when I set my primary ket to a MongoDB.Bson.ObjectId:
Severity Code Description Project File Line Suppression State
Error Fody/Realm: Item.ID is marked as [PrimaryKey] which is only allowed on integral and string types, not on MongoDB.Bson.ObjectId. StretchedPenny D:\projects\MongoDBSP\StretchedPenny\StretchedPenny\StretchedPenny\Models\Items.cs 9
In Realm, what is the recommended way to create a unique key?
Ahhh… yes. I see now. It really needs to be more explicit. I did not take away from that I needed to install the beta package. I suggest:
Add the Realm Beta Package
In the search bar, search for Realm . Check the “Show pre-release packages” checkbox and choose the latest beta release .Select the result and click Add Package. When prompted, select all projects and click Ok.