using MongoDB.Bson; using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Attributes; using MongoDB.Driver; var client = new MongoClient("mongodb://***"); var db = client.GetDatabase("test"); BsonClassMap.RegisterClassMap(); BsonClassMap.RegisterClassMap(); var collBase = db.GetCollection("OfTypeUpdatePipeline"); var collDerived = collBase.OfType(); // Works collDerived.UpdateOne( x => x.Key == "TestKey", Builders.Update.Set(x => x.Value, "Plain update"), new UpdateOptions() { IsUpsert = true }); var pipeline = new EmptyPipelineDefinition() .AppendStage(new BsonDocument { { "$set", new BsonDocument { { nameof(DerivedClass.Value), "Pipeline" } } } }); var update = Builders.Update.Pipeline(pipeline); // Fails with: 'Unable to cast object of type 'MongoDB.Bson.BsonArray' to type 'MongoDB.Bson.BsonDocument'.' collDerived.UpdateOne( x => x.Key == "TestKey", pipeline, new UpdateOptions() { IsUpsert = true }); public class BaseClass { [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)] public string Id { get; set; } public string Key { get; set; } } public class DerivedClass : BaseClass { public string Value { get; set; } }