我现在开始使用 CosmosDB,在尝试在数据库中插入一些数据时遇到以下错误:
The input content is invalid because the required properties - 'id; ' - are missing.
Run Code Online (Sandbox Code Playgroud)
我知道我的文档中应该有一个string被调用的字段,但即使在我将注释id添加到对象的字段后,错误仍然存在。[JsonPropertyName("id")]Id
这是对 CosmosDB 的调用:
var insertionResponse = await container.CreateItemAsync<Article>(
item: article,
partitionKey: new PartitionKey(article.Id.ToString())
);
Run Code Online (Sandbox Code Playgroud)
这是Article课程:
public partial class Article
{
[JsonPropertyName("id")]
public Guid Id { get; set; }
public Guid CreatedBy { get; set; }
public DateTime CreatedOn { get; set; }
public string Title { get; set; }
public string Body { get; …Run Code Online (Sandbox Code Playgroud)