我試圖使用MySql和EntityFramework遷移,但似乎是錯誤的東西。指定的密鑰太長;最大密鑰長度是767字節mysql,entityframework(遷移)
拋出此異常:
指定的鍵過長;最大密鑰長度爲767個字節
請幫我:(
我的新類:
public class user
{
public user()
{
}
[Key]
[Column("id")]
public int Id { get; set; }
[StringLength(20)]
[Column("name")]
public string Name { get; set; }
[Column("age")]
public int Age { get; set; }
}
public class PmtDbContext : DbContext
{
static PmtDbContext()
{
Database.SetInitializer(new MigrateDatabaseToLatestVersion<PmtDbContext, Migrations.Configuration>());
}}
internal sealed class Configuration : DbMigrationsConfiguration<PmtDbContext>
{
public Configuration()
{
AutomaticMigrationsEnabled = true;
AutomaticMigrationDataLossAllowed = true;
SetSqlGenerator("MySql.Data.MySqlClient", new MySqlMigrationSqlGenerator());
}}
爲對象做什麼平常鍵值的樣子?是以前的另一個類型的關鍵列? – DevilSuichiro
@DevilSuichiro我所有班級的鑰匙都是這樣的代碼: [Key] [Col umn(「id」)] public int Id {get;組; } – Mahrooy