{"action":"opened","issue":{"url":"https://api.github.com/repos/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues/136","repository_url":"https://api.github.com/repos/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql","labels_url":"https://api.github.com/repos/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues/136/labels{/name}","comments_url":"https://api.github.com/repos/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues/136/comments","events_url":"https://api.github.com/repos/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues/136/events","html_url":"https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues/136","id":193116924,"number":136,"title":"Specified Key was too long with IdentityContext and InnoDB","user":{"login":"Mats391","id":868580,"avatar_url":"https://avatars.githubusercontent.com/u/868580?v=3","gravatar_id":"","url":"https://api.github.com/users/Mats391","html_url":"https://github.com/Mats391","followers_url":"https://api.github.com/users/Mats391/followers","following_url":"https://api.github.com/users/Mats391/following{/other_user}","gists_url":"https://api.github.com/users/Mats391/gists{/gist_id}","starred_url":"https://api.github.com/users/Mats391/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mats391/subscriptions","organizations_url":"https://api.github.com/users/Mats391/orgs","repos_url":"https://api.github.com/users/Mats391/repos","events_url":"https://api.github.com/users/Mats391/events{/privacy}","received_events_url":"https://api.github.com/users/Mats391/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-12-02T13:32:37Z","updated_at":"2016-12-02T13:32:37Z","closed_at":null,"body":"This got reported before, but caleblloyd asked me to make new issue. \r\nOriginal: https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues/81\r\nWhen using the IdentityContext for asp.net Identity, I get the error \"Specified key was too long; max key length is 767 bytes\"\r\nStack trace:\r\n```\r\nMySql.Data.MySqlClient.MySqlException: Specified key was too long; max key length is 767 bytes\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n\r\n   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n   at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1.ConfiguredValueTaskAwaiter.GetR\r\nesult()\r\n   at MySql.Data.MySqlClient.MySqlDataReader.<ReadResultSetHeaderAsync>d__56.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n\r\n   at MySql.Data.MySqlClient.MySqlDataReader.<CreateAsync>d__50.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n\r\n   at MySql.Data.MySqlClient.CommandExecutors.TextCommandExecutor.<ExecuteReaderAsync>d__3.MoveNext(\r\n)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n\r\n   at MySql.Data.MySqlClient.CommandExecutors.TextCommandExecutor.<ExecuteNonQueryAsync>d__1.MoveNex\r\nt()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n\r\n   at MySql.Data.MySqlClient.MySqlCommand.<ExecuteNonQueryAsync>d__46.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n\r\n   at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()\r\n   at Microsoft.EntityFrameworkCore.Storage.Internal.MySqlRelationalCommand.<ExecuteAsync>d__3.MoveN\r\next()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n\r\n   at Microsoft.EntityFrameworkCore.Storage.Internal.MySqlRelationalCommand.Execute(IRelationalConne\r\nction connection, String executeMethod, IReadOnlyDictionary`2 parameterValues, Boolean closeConnecti\r\non)\r\n   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteNonQuery(IRelationalCo\r\nnnection connection, IReadOnlyDictionary`2 parameterValues)\r\n   at Microsoft.EntityFrameworkCore.Migrations.MigrationCommand.ExecuteNonQuery(IRelationalConnectio\r\nn connection, IReadOnlyDictionary`2 parameterValues)\r\n   at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationCommandExecutor.ExecuteNonQuery(IEn\r\numerable`1 migrationCommands, IRelationalConnection connection)\r\n   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)\r\n   at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targe\r\ntMigration, String contextType)\r\n   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_1.<.c\r\ntor>b__0()\r\n   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)\r\nSpecified key was too long; max key length is 767 bytes\r\n```\r\n\r\nI already tried all the suggetions from the original issue. I set all keys to have a max length that should be small enough and made sure that the DB uses utf8_unicode_ci. I even tried way lower values then the ones below.\r\n```\r\nmodelBuilder.Entity<UserEntity>(entity => entity.Property(m => m.Id).HasMaxLength(80));\r\nmodelBuilder.Entity<IdentityRole>(entity => entity.Property(m => m.Id).HasMaxLength(80));\r\nmodelBuilder.Entity<IdentityUserLogin<string>>(entity => entity.Property(m => m.LoginProvider).HasMaxLength(80));\r\nmodelBuilder.Entity<IdentityUserLogin<string>>(entity => entity.Property(m => m.ProviderKey).HasMaxLength(80));\r\nmodelBuilder.Entity<IdentityUserLogin<string>>(entity => entity.Property(m => m.UserId).HasMaxLength(80));\r\nmodelBuilder.Entity<IdentityUserRole<string>>(entity => entity.Property(m => m.UserId).HasMaxLength(80));\r\nmodelBuilder.Entity<IdentityUserRole<string>>(entity => entity.Property(m => m.RoleId).HasMaxLength(80));\r\nmodelBuilder.Entity<IdentityUserToken<string>>(entity => entity.Property(m => m.UserId).HasMaxLength(80));\r\nmodelBuilder.Entity<IdentityUserToken<string>>(entity => entity.Property(m => m.LoginProvider).HasMaxLength(80));\r\nmodelBuilder.Entity<IdentityUserToken<string>>(entity => entity.Property(m => m.Name).HasMaxLength(80));\r\nmodelBuilder.Entity<IdentityUserClaim<string>>(entity => entity.Property(m => m.Id).HasMaxLength(80));\r\nmodelBuilder.Entity<IdentityUserClaim<string>>(entity => entity.Property(m => m.UserId).HasMaxLength(80));\r\nmodelBuilder.Entity<IdentityRoleClaim<string>>(entity => entity.Property(m => m.Id).HasMaxLength(80));\r\nmodelBuilder.Entity<IdentityRoleClaim<string>>(entity => entity.Property(m => m.RoleId).HasMaxLength(80));\r\n```\r\n\r\nGist of Migration:\r\nhttps://gist.github.com/Mats391/51a3b9f9103f4c3902dfa1bec5f1d678\r\n\r\nThe weird part is that it creates everything fine. Only the migration does not get added into the `__efmigrationshistory`. I suspect the error get thrown when it tries to write into the history. The history has PK MigrationId VARCHAR(95). I can use the DbContext fine, only applying new migrations forces me to recreate everything from scratch. \r\nI found out that it only happens when I set it to use InnoDB, If I keep it as MyISAM everything works fine.\r\n\r\nVersions\r\n\"Microsoft.EntityFrameworkCore\": \"1.1.0-preview1-final\",\r\n\"Microsoft.AspNetCore.Identity.EntityFrameworkCore\": \"1.1.0-preview1-final\",\r\n\"Pomelo.EntityFrameworkCore.MySql\": \"1.1.0-preview1-*\""}}
{"actor":{"display_login":"Mats391"}}