0
創建排序和分區鍵創建表時收到此錯誤:上DynamoDb
"One or more parameter values were invalid:
Number of attributes in KeySchema does not
exactly match number of attributes defined in AttributeDefinitions"
我跟着例子here
我有兩節我的鍵控屬性。我唯一想知道的是我的鍵控屬性類型是字符串,而不是數字。我無法以這種或那種方式找到答案。
我實現
private static void CreateTableMember()
{
string tableName = "Member";
var response = client.CreateTable(new CreateTableRequest
{
TableName = tableName,
AttributeDefinitions = new List<AttributeDefinition>()
{
new AttributeDefinition
{
AttributeName = "MasterCustomerId",
AttributeType = "S"
},
new AttributeDefinition
{
AttributeName = "LastName",
AttributeType = "S"
},
new AttributeDefinition
{
AttributeName = "DistrictId",
AttributeType = "S"
},
new AttributeDefinition
{
AttributeName = "EmailAddress",
AttributeType = "S"
},
new AttributeDefinition
{
AttributeName = "FirstName",
AttributeType = "S"
}
},
KeySchema = new List<KeySchemaElement>()
{
new KeySchemaElement
{
AttributeName = "MasterCustomerId",
KeyType = "HASH" // Partition Key
},
new KeySchemaElement
{
AttributeName = "LastName",
KeyType = "RANGE" //Sort key
}
},
ProvisionedThroughput = new ProvisionedThroughput
{
ReadCapacityUnits = 10,
WriteCapacityUnits = 5
}
});
WaitTillTableCreated(client, tableName, response);
}