0

我最近使用以下配置从abp.io下载了一个项目:

Project Type: Application
UI Framework: Angular
Database Provider: Entity Framework Core
Separate Identity Server: Yes

更新数据库时,我在包管理器控制台中收到以下错误。

BLOB/TEXT column 'Value' used in key specification without a key length

以下是迁移脚本:

migrationBuilder.CreateTable(
            name: "IdentityServerApiSecrets",
            columns: table => new
            {
                Type = table.Column<string>(maxLength: 250, nullable: false),
                Value = table.Column<string>(maxLength: 4000, nullable: false),
                ApiResourceId = table.Column<Guid>(nullable: false),
                Description = table.Column<string>(maxLength: 2000, nullable: true),
                Expiration = table.Column<DateTime>(nullable: true)
            },
            constraints: table =>
            {
                table.PrimaryKey("PK_IdentityServerApiSecrets", x => new { x.ApiResourceId, x.Type, x.Value });
                table.ForeignKey(
                    name: "FK_IdentityServerApiSecrets_IdentityServerApiResources_ApiResou~",
                    column: x => x.ApiResourceId,
                    principalTable: "IdentityServerApiResources",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

我删除了旧的迁移并添加了一个新的迁移,结果是上面的脚本。

我将“Value”属性的 maxLength 更改为 1000。现在它显示以下错误消息:

Specified key was too long; max key length is 3072 bytes

我尝试在 MySql Workbench 中运行以下脚本 [在包管理器控制台中生成]。这也给了我同样的错误信息。

CREATE TABLE `IdentityServerApiSecrets` (
    `Type` varchar(250) CHARACTER SET utf8mb4 NOT NULL,
    `Value` varchar(1000) CHARACTER SET utf8mb4 NOT NULL,
    `ApiResourceId` varchar(36) CHARACTER SET utf8mb4 NOT NULL,
    `Description` varchar(2000) CHARACTER SET utf8mb4 NULL,
    `Expiration` datetime(6) NULL,
    CONSTRAINT `PK_IdentityServerApiSecrets` PRIMARY KEY (`ApiResourceId`, `Type`, `Value`),
    CONSTRAINT `FK_IdentityServerApiSecrets_IdentityServerApiResources_ApiResou~` FOREIGN KEY (`ApiResourceId`) REFERENCES `IdentityServerApiResources` (`Id`) ON DELETE CASCADE
;

请帮忙。

4

1 回答 1

0

在您的 Migration DbContext 上执行此操作。

builder.ConfigureIdentityServer(options =>
{
    options.DatabaseProvider = EfCoreDatabaseProvider.MySql;
});
于 2020-04-02T05:52:37.793 回答