-
Notifications
You must be signed in to change notification settings - Fork 0
Table Operations
Mark Lauter edited this page May 16, 2026
·
5 revisions
DynamoDbLite supports the full lifecycle of DynamoDB table management: creation with key schemas and indexes, deletion, description, listing, and updates (GSI modifications). See Working with Tables in the AWS docs.
Creates a new table with the specified key schema, attribute definitions, and optional indexes.
Task<CreateTableResponse> CreateTableAsync(CreateTableRequest request, CancellationToken ct = default)
Task<CreateTableResponse> CreateTableAsync(
string tableName,
List<KeySchemaElement> keySchema,
List<AttributeDefinition> attributeDefinitions,
ProvisionedThroughput provisionedThroughput,
CancellationToken ct = default)- TableName (required) — name of the table to create
- KeySchema (required) — exactly one HASH key, optionally one RANGE key
- AttributeDefinitions (required) — type definitions for all key attributes (table + index keys)
- ProvisionedThroughput — read/write capacity (stored but not enforced)
- GlobalSecondaryIndexes — up to 5 GSIs (see Secondary Indexes)
- LocalSecondaryIndexes — up to 5 LSIs (must share the table's partition key)
- Tags — up to 50 key-value tags (see Tags and Admin)
await client.CreateTableAsync(new CreateTableRequest
{
TableName = "Orders",
KeySchema =
[
new KeySchemaElement { AttributeName = "CustomerId", KeyType = KeyType.HASH },
new KeySchemaElement { AttributeName = "OrderId", KeyType = KeyType.RANGE }
],
AttributeDefinitions =
[
new AttributeDefinition { AttributeName = "CustomerId", AttributeType = ScalarAttributeType.S },
new AttributeDefinition { AttributeName = "OrderId", AttributeType = ScalarAttributeType.S }
],
ProvisionedThroughput = new ProvisionedThroughput
{
ReadCapacityUnits = 5,
WriteCapacityUnits = 5
}
});- Key schema must have exactly one HASH key and at most one RANGE key
- All key attribute names must appear in
AttributeDefinitions - Attribute definitions must exactly cover all referenced key attributes (table + indexes)
- Duplicate table names throw
ResourceInUseException - GSI limit: 5 per table; LSI limit: 5 per table
- Table status is immediately
ACTIVE(noCREATINGphase) - Provisioned throughput is stored but not enforced (no throttling)
Deletes a table and all its data, indexes, TTL configuration, and tags.
Task<DeleteTableResponse> DeleteTableAsync(DeleteTableRequest request, CancellationToken ct = default)
Task<DeleteTableResponse> DeleteTableAsync(string tableName, CancellationToken ct = default)await client.DeleteTableAsync("Orders");- Deletes all items in the table
- Drops all index tables (GSI + LSI)
- Removes TTL configuration
- Removes all tags
- Throws
ResourceNotFoundExceptionif the table doesn't exist - Deletion is synchronous — the table is gone before the call returns. The response carries
TableStatus.DELETINGto satisfy theDeleteTableResponsecontract; no polling is needed.
Returns metadata about a table including key schema, indexes, item count, and size.
Task<DescribeTableResponse> DescribeTableAsync(DescribeTableRequest request, CancellationToken ct = default)
Task<DescribeTableResponse> DescribeTableAsync(string tableName, CancellationToken ct = default)var response = await client.DescribeTableAsync("Orders");
var description = response.Table;
Console.WriteLine(description.TableName); // "Orders"
Console.WriteLine(description.TableStatus); // ACTIVE
Console.WriteLine(description.ItemCount); // current item count
Console.WriteLine(description.TableSizeBytes); // sum of item_json lengths
Console.WriteLine(description.TableArn); // arn:aws:dynamodb:local:000000000000:table/Orders| Field | Description |
|---|---|
TableName |
Table name |
TableStatus |
Always ACTIVE
|
KeySchema |
Partition and sort key definitions |
AttributeDefinitions |
Attribute type definitions |
ProvisionedThroughput |
Stored throughput values |
CreationDateTime |
When the table was created |
ItemCount |
Exact count (updated on every write) |
TableSizeBytes |
Sum of JSON payload lengths |
TableArn |
arn:aws:dynamodb:local:000000000000:table/{name} |
GlobalSecondaryIndexes |
GSI descriptions (if any) |
LocalSecondaryIndexes |
LSI descriptions (if any) |
-
ItemCountandTableSizeBytesare exact (DynamoDB updates these approximately every 6 hours) -
TableArnuses a local format with account000000000000
Returns table names with optional pagination.
Task<ListTablesResponse> ListTablesAsync(CancellationToken ct = default)
Task<ListTablesResponse> ListTablesAsync(string exclusiveStartTableName, CancellationToken ct = default)
Task<ListTablesResponse> ListTablesAsync(string exclusiveStartTableName, int? limit, CancellationToken ct = default)
Task<ListTablesResponse> ListTablesAsync(int? limit, CancellationToken ct = default)
Task<ListTablesResponse> ListTablesAsync(ListTablesRequest request, CancellationToken ct = default)// List all tables
var response = await client.ListTablesAsync();
foreach (var name in response.TableNames)
Console.WriteLine(name);
// Paginate with limit
var page = await client.ListTablesAsync(new ListTablesRequest { Limit = 10 });
while (page.LastEvaluatedTableName is not null)
{
page = await client.ListTablesAsync(page.LastEvaluatedTableName, 10);
}- Default limit is 100 (matches DynamoDB)
- Tables are returned in alphabetical order
Modifies an existing table. Supports GSI creation (with backfill), GSI deletion, and provisioned-throughput updates (accepted but not enforced).
Task<UpdateTableResponse> UpdateTableAsync(UpdateTableRequest request, CancellationToken ct = default)
Task<UpdateTableResponse> UpdateTableAsync(string tableName, ProvisionedThroughput throughput, CancellationToken ct = default)await client.UpdateTableAsync(new UpdateTableRequest
{
TableName = "Orders",
AttributeDefinitions =
[
new AttributeDefinition { AttributeName = "CustomerId", AttributeType = ScalarAttributeType.S },
new AttributeDefinition { AttributeName = "OrderId", AttributeType = ScalarAttributeType.S },
new AttributeDefinition { AttributeName = "Status", AttributeType = ScalarAttributeType.S }
],
GlobalSecondaryIndexUpdates =
[
new GlobalSecondaryIndexUpdate
{
Create = new CreateGlobalSecondaryIndexAction
{
IndexName = "StatusIndex",
KeySchema =
[
new KeySchemaElement { AttributeName = "Status", KeyType = KeyType.HASH }
],
Projection = new Projection { ProjectionType = ProjectionType.ALL }
}
}
]
});await client.UpdateTableAsync(new UpdateTableRequest
{
TableName = "Orders",
GlobalSecondaryIndexUpdates =
[
new GlobalSecondaryIndexUpdate
{
Delete = new DeleteGlobalSecondaryIndexAction { IndexName = "StatusIndex" }
}
]
});- GSI Create: creates the index table and backfills all existing items synchronously
- GSI Delete: drops the index table and updates metadata
- Throughput Update: accepted but has no effect (no throttling)
- GSI creation is synchronous (no
CREATINGstatus transition) - Backfill happens immediately within the same call
- LSIs must be defined at table creation (matches DynamoDB)
- Item Operations — reading and writing data
- Secondary Indexes — adding GSIs and LSIs
Repo · NuGet · API Parity
Getting started
Reference
- Table Operations
- Item Operations
- Query and Scan
- Batch Operations
- Transactions
- Secondary Indexes
- TTL
- Tags and Admin
- DI and Configuration
- Concurrency
- Performance
- API Parity
- FAQ
Recipes
- DynamoDBContext for tests
- xUnit per-test isolation
- ASP.NET Core integration test fixture
- Migrating tests off DynamoDB Local
Internals