DynamoDB model/schema 创建?

DynamoDB model/schema creation?

我有一个用 C#/.NET 编写的应用程序,它是一个非常简单的论坛网站。 目前,我正在使用带有 EntityFramework CodeMigration 作为我的数据访问层的 SqlServer。

我正在考虑将所有数据迁移到 DynamoDB,我已经尝试了一些教程并阅读了一些文档,但我目前在创建模型方面遇到困难...

使用 EntityFramework CodeMigration,我只是创建了一些 C# 实体,然后使用 EF 迁移脚手架编写 C# 代码来设置我的数据库(此脚本包含我所有的 tables/indexes/Keys/.. . 创作)。 我发现这非常有用,我所有的数据库模式都是脚本化的,易于更新和与我的项目的其余部分一起版本化。

那么现在我的问题是,有没有办法使用 DynamoDB .NET SDK 做同样的事情?

我已经阅读了以下有关 table 创作的文档,但我已经将近 50 table 了,手动编写所有设置真的很痛苦,而且我已经定义了我的实体,它们必须是自动创建 table 基础和我的实体的东西?

这是我正在使用的示例实体,table 创建脚本对应:

[DynamoDBTable("ProductCatalog")]
public class Book
{
    [DynamoDBHashKey]
    public int Id { get; set; }
    [DynamoDBProperty]
    public string Title { get; set; }
    [DynamoDBProperty]
    public string ISBN { get; set; }
    [DynamoDBProperty("Authors")]
    public List<string> BookAuthors { get; set; }
}

var request = new CreateTableRequest
{
    TableName = "ProductCatalog",
    AttributeDefinitions = new List<AttributeDefinition>
    {
        new AttributeDefinition
        {
        AttributeName = "Id",
        AttributeType = "N"
        },
        new AttributeDefinition
        {
        AttributeName = "ISBN",
        AttributeType = "S"
        }
    },
    KeySchema = new List<KeySchemaElement>
    {
        new KeySchemaElement
        {
        AttributeName = "Id",
        KeyType = "HASH"
        },
        new KeySchemaElement
        {
        AttributeName = "ISBN",
        KeyType = "RANGE"
        }
    },
    ProvisionedThroughput = new ProvisionedThroughput
    {
        ReadCapacityUnits = 1,
        WriteCapacityUnits = 1
    },

};
var response = client.CreateTable(request);

有什么建议吗?让我想念什么?

遗憾的是,目前无法使用适用于 .NET 的 AWS 开发工具包执行此操作。如果你愿意,你可以为这个 in the official GitHub repo 的功能请求打开一个问题。该 SDK 也是开源的,因此如果您确实实现了您认为对其他开发人员有益的东西,您可以提交拉取请求以将您的源代码包含在 SDK 中。