C# MongoDB MongoDB.Bson.BsonSerializationException: '' cannot use element name '' because it is already being used by property '' of type ''

问题描述 投票:0回答:0

我有以下数据模型:(使用 C# 和 MongoDB 工作)

public class aClass
{
    public virtual string Content { get; set; }
}
public class aClassDao
{
    public override string Content { get; set; }
}
public class MongoDbContext
{
    public IMongoDatabase Database { get; }
    public IMongoCollection<aClassDao> Classes=> Database.GetCollection<aClassDao>("Classes");

    public MongoDbContext()
    {
        // some connection logic
    }
}

当我启动我的应用程序时,出现以下错误:

MongoDB.Bson.BsonSerializationException: The property 'Content' of type 'aClassDao' cannot use element name 
'Content' because it is already being used by property 'Content' of type 'aClass'.
c# asp.net mongodb inheritance serialization
© www.soinside.com 2019 - 2024. All rights reserved.