Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Mysql EntityFramework issue - Specified key was too long; max key length is 3072 bytes

$
0
0

Hello,

when i type:

$ dotnet ef database update

i get this error:

Specified key was too long; max key length is 3072 bytes

The table which cause this error is a built-in Microsoft table for user management:

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
);

I tried to add this to OnModelCreating:

modelBuilder.Entity<Utilisateurs>(entity => entity.Property(m => m.NormalizedEmail).HasMaxLength(200));
modelBuilder.Entity<Utilisateurs>(entity => entity.Property(m => m.NormalizedUserName).HasMaxLength(200));
modelBuilder.Entity<IdentityRole>(entity => entity.Property(m => m.NormalizedName).HasMaxLength(200));
modelBuilder.Entity<IdentityUserLogin<string>>(entity => entity.Property(m => m.UserId).HasMaxLength(200));
modelBuilder.Entity<IdentityUserRole<string>>(entity => entity.Property(m => m.UserId).HasMaxLength(200));
modelBuilder.Entity<IdentityUserRole<string>>(entity => entity.Property(m => m.RoleId).HasMaxLength(200));
modelBuilder.Entity<IdentityUserToken<string>>(entity => entity.Property(m => m.UserId).HasMaxLength(200));
modelBuilder.Entity<IdentityUserClaim<string>>(entity => entity.Property(m => m.UserId).HasMaxLength(200));
modelBuilder.Entity<IdentityRoleClaim<string>>(entity => entity.Property(m => m.RoleId).HasMaxLength(200));

But it does not work anymore

Thanks for your help


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>