2017-02-20 3 views
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); 

    } 

ответ

0

Вам не нужно указывать, не ключевые атрибуты при создании таблицы DynamoDB. У DynamoDB нет фиксированной схемы. Вместо этого каждый элемент данных может иметь различное количество атрибутов (кроме обязательных ключевых атрибутов).

Снятие неквалифицированных атрибутов устранено проблема