PartitionKey extracted from document doesn't match the one specified in the header on CreateItemAsync

前端 未结 1 556
后悔当初
后悔当初 2020-12-20 19:26

I have a bit of a problem using Microsoft.Azure.Cosmos version 3.2.0,

upon running

await this.Container.CreateItemAsync(logEntity, new         


        
相关标签:
1条回答
  • 2020-12-20 19:53

    I've overlooked that when I have created the container

    this.Container = await this.Database.CreateContainerIfNotExistsAsync("testContainer", "/id");
    

    I have specified partitionKeyPath as beeing the /id.

    It also seems that the partition key must reside on the object and must have a json property of partitionKeyPath property name without / like:

    [JsonProperty(PropertyName = "partition")]
    public string Partition { get; set; }
    

    if partitionKeyPath is /partition

    this.Container = await this.Database.CreateContainerIfNotExistsAsync("testContainer", "/partition");
    

    Sorry if this is obvious, I have just started playing around with CosmoDb.

    0 讨论(0)
提交回复
热议问题