首页 > 解决方案 > MongoDB.Driver.MongoWriteException:'写入操作导致错误。无法索引并行数组'

问题描述

[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string Id { get; set; }

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

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

[BsonElement("Prop03")]
public string[] Prop03{ get; set; }

[BsonElement("Prop04")]
public List<Test> Prop04{ get; set; }

我正在使用 C#(Dot Net Core)在 mongoDB 中插入上述结构/模型,但我收到以下异常:

**MongoDB.Driver.MongoWriteException: '写入操作导致错误。无法索引并行数组 [Prop03] [Prop04]'

内部异常 MongoBulkWriteException`1:批量写入操作导致一个或多个错误。无法索引并行数组 [Prop03] [Prop04]**

我不知道我收到上述异常的原因。

我已经尝试了与前两天不同的技巧,但没有成功。

标签: arraysmongodbindexingnosqlparallel-arrays

解决方案


终于问题解决了!

我在并行的数组和列表字段上应用数据库索引,这在 MongoDB 中是不允许的。


推荐阅读