【发布时间】:2019-02-28 06:34:21
【问题描述】:
所以我使用 Microsoft 的 Microsoft.Azure.DocumentDB.Core api 从我的 .Net Core 应用程序连接到我的 Cosmos DB。
一切正常,我可以创建、编辑和获取文档,以及创建新的数据库或集合。如果我使用 DocumentDB.Core api 创建数据库或集合,我可以在我的 azure 门户中看到它们。但是,当我创建文档时,我看不到它们。每当我尝试加载我的文档时,我收到此错误的次数等于我拥有的文档数。
Error while fetching page of documents {"code":400,"body":"Command find failed: Unknown server error occurred when processing this request.."}
我知道我有现有的记录,因为如果我保存我在创建时返回的 ID,然后我可以使用 DocumentDB.Core api 查找它。
这是我传递的模型:
public class Api
{
public Api()
{
Client = new ExpandoObject();
}
[JsonProperty(PropertyName = "id")]
public string Id { get; set; }
public ExpandoObject Client { get; set; }
}
现在,在我切换到 DocumentDB.Core 之前,我使用的是 MongoDB.Driver,这是我的模型:
public class Api
{
public Api()
{
Client = new ExpandoObject();
}
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string Id { get; set; }
[BsonElement("client")]
public ExpandoObject Client { get; set; }
}
使用 MongoDB.Driver 和上述模型,我能够在 azure 门户中看到我的数据。
使用 Microsoft 自己的工具在 Azure CosmosDB 门户中看不到数据是否有原因?我错过了财产吗?我注意到唯一不同的是,使用 MongoDB.Drive,我创建的文档中的 id 是 _id,使用 DocumentDB.Core,我创建的文档中的 id 是 id。我不确定这是否重要,或者如何解决。
【问题讨论】:
标签: mongodb azure asp.net-core azure-cosmosdb