mysql - 将 ASP.NET MVC MySql db 迁移到 PLESK
问题描述
我已将我的 Asp.NET 项目发布到 Plesk,它已成功完成。现在我需要使用 PM 更新数据库,但它会为“ASPNETROLES”创建表,然后引发异常。
指定的密钥太长;最大密钥长度为 767 字节
我找到了以下解决方案,但没有一个有效:
https://bugs.mysql.com/bug.php?id=81817
指定的密钥太长;实体框架 6 中的最大密钥长度为 767 字节 Mysql 错误
我尝试了以下代码但失败了:
[DbConfigurationType(typeof(MySqlEFConfiguration))]
public class AppIdentityDbContext : IdentityDbContext<ApplicationUser>
{
public AppIdentityDbContext() : base("myConnection")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<HistoryRow>().HasKey<string>(h => h.MigrationId);
modelBuilder.Entity<HistoryRow>().Property(h => h.MigrationId).HasMaxLength(100).IsRequired();
modelBuilder.Entity<HistoryRow>().Property(h => h.ContextKey).HasMaxLength(200).IsRequired();
modelBuilder.Entity<ApplicationUser>().Property(u => u.Id).HasMaxLength(128);
modelBuilder.Entity<ApplicationUser>().Property(u => u.UserName).HasMaxLength(128);
modelBuilder.Entity<ApplicationUser>().Property(u => u.Email).HasMaxLength(128);
modelBuilder.Entity<IdentityRole>().Property(r => r.Name).HasMaxLength(128);
}
它应该创建所有 ASPNET 表,还应该将主键设置为自动递增。
有人可以分享在 Plesk 上部署的指南吗?
解决方案
推荐阅读
- excel - 如何将图表中一个条形的颜色设置为透明?
- php - 组织数据库来存储/获取用户事件和日期
- java - 如何将调用注释的类名和方法作为“值”传递给注释属性
- mysql - Express mysql connection err Error: connect ETIMEDOUT on Mac OS
- typescript - 打字稿简单的减速器组成
- javascript - 只允许数字和逗号
- c++ - 使用 CMAke 将文件添加到 Vs 项目,以便在构建期间将其复制到输出目录
- javascript - 将第一个 observable 的结果传递给 switchMap 中的 observable
- python-3.x - 摆脱 Sklearn pipeline.predict() 的打印输出
- java - 评估具有依赖关系的 kotlin 脚本文件