title: Mysql Entity Framework issue - Specified key was too long; max key length is 3072 bytes
body: <p>When I use this command:</p>
  
  <pre><code>$ dotnet ef database update
  </code></pre>
  
  <p>I get this error:</p>
  
  <blockquote>
    <p>Specified key was too long; max key length is 3072 bytes</p>
  </blockquote>
  
  <p>The table which cause this error is a built-in Microsoft table for user management:</p>
  
  <pre><code>CREATE TABLE `AspNetUserLogins` 
  (
      `LoginProvider` varchar(767) NOT NULL,
      `ProviderKey` varchar(767) NOT NULL,
      `ProviderDisplayName` text NULL,
      `UserId` varchar(767) NOT NULL,
  
      PRIMARY KEY (`LoginProvider`, `ProviderKey`),
      CONSTRAINT `FK_AspNetUserLogins_AspNetUsers_UserId` 
          FOREIGN KEY (`UserId`) REFERENCES `AspNetUsers` (`Id`) 
          ON DELETE CASCADE
  );
  </code></pre>
  
  <p>I tried to add this to <code>OnModelCreating</code>:</p>
  
  <pre><code>modelBuilder.Entity&lt;Utilisateurs&gt;(entity =&gt; entity.Property(m =&gt; m.NormalizedEmail).HasMaxLength(200));
  modelBuilder.Entity&lt;Utilisateurs&gt;(entity =&gt; entity.Property(m =&gt; m.NormalizedUserName).HasMaxLength(200));
  modelBuilder.Entity&lt;IdentityRole&gt;(entity =&gt; entity.Property(m =&gt; m.NormalizedName).HasMaxLength(200));
  modelBuilder.Entity&lt;IdentityUserLogin&lt;string&gt;&gt;(entity =&gt; entity.Property(m =&gt; m.UserId).HasMaxLength(200));
  modelBuilder.Entity&lt;IdentityUserRole&lt;string&gt;&gt;(entity =&gt; entity.Property(m =&gt; m.UserId).HasMaxLength(200));
  modelBuilder.Entity&lt;IdentityUserRole&lt;string&gt;&gt;(entity =&gt; entity.Property(m =&gt; m.RoleId).HasMaxLength(200));
  modelBuilder.Entity&lt;IdentityUserToken&lt;string&gt;&gt;(entity =&gt; entity.Property(m =&gt; m.UserId).HasMaxLength(200));
  modelBuilder.Entity&lt;IdentityUserClaim&lt;string&gt;&gt;(entity =&gt; entity.Property(m =&gt; m.UserId).HasMaxLength(200));
  modelBuilder.Entity&lt;IdentityRoleClaim&lt;string&gt;&gt;(entity =&gt; entity.Property(m =&gt; m.RoleId).HasMaxLength(200));
  </code></pre>
  
  <p>But it does not work anymore.</p>
  
  <p>Thanks for your help</p>
  
  <p>** EDIT **</p>
  
  <p>I also tried:</p>
  
  <pre><code>modelBuilder.Entity&lt;IdentityUserLogin&lt;string&gt;&gt;(entity =&gt; entity.Property(m =&gt; m.LoginProvider).HasMaxLength(200));
  modelBuilder.Entity&lt;IdentityUserLogin&lt;string&gt;&gt;(entity =&gt; entity.Property(m =&gt; m.ProviderKey).HasMaxLength(200));
  </code></pre>