使用Volo ABP for MySQL进行迁移时出现问题



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

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

更新数据库时,我在Package Mangger控制台中收到以下错误。

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中运行以下脚本[在Package Manager控制台中生成]。这也给了我同样的错误信息。

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
;

请帮忙。

在迁移DbContext上执行此操作。

builder.ConfigureIdentityServer(options =>
{
options.DatabaseProvider = EfCoreDatabaseProvider.MySql;
});

最新更新