Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'MongoDB.Bson.BsonElement' is not an attribute class on simple POCO

This is my POCO:

private class Widget
{
    public int Id { get; set; }

    [BsonElement("x")]
    public int X { get; set; }

    public override string ToString()
    {
        return "Id: " + Id + " X: " + X;
    }
}

And I get an error on the BsonElement attribute:

enter image description here

I'm using:
Framework: .NET v4.5,
References: MongoDB.Driver.dll v2.0.1, MongoDB.BSON.dll v2.0.1
IDE: Visual Studio Premium 2012

Seems to work fine for the guy in this video.

like image 669
SNag Avatar asked Feb 10 '23 00:02

SNag


1 Answers

Found it. This using declaration was required:

using MongoDB.Bson.Serialization.Attributes;

like image 159
SNag Avatar answered Feb 15 '23 10:02

SNag