2

I have an application built with asp.net-core 2.0.

I used Pomelo.EntityFrameworkCore.MySql to integrate MySql.

The configuration which I use in Startup.cs is:

public void ConfigureServices(IServiceCollection services)
{
    services.AddDbContext<ApplicationDbContext>(options => options.UseMySql("Server=localhost;port=3306;database=MyDB;user=MyDb_user;password=test123");
    ...
}

The DbContext for ApplicationUser which comes with the framework looks like:

public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
    public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
        : base(options)
    {
    }

    protected override void OnModelCreating(ModelBuilder builder)
    {
        base.OnModelCreating(builder);
        // Customize the ASP.NET Identity model and override the defaults if needed.
        // For example, you can rename the ASP.NET Identity table names and more.
        // Add your customizations after calling base.OnModelCreating(builder);
    }
}

Now in MySql I created MyDB with Collation "utf8_general_ci".

But on DB migrate I am getting the error:

'Specified key was too long; max key length is 1000 bytes'

All solutions which I found to get this working with utf8 doesn't work with asp.net-core 2.0

Is there any solution for this with asp.net-core 2.0

carpics
  • 2,272
  • 4
  • 28
  • 56
  • Turn unicode off for Email and Username – Musab Aug 23 '17 at 12:07
  • Check these answers out, may be they will help: https://stackoverflow.com/questions/3489041/mysqlerror-specified-key-was-too-long-max-key-length-is-1000-bytes https://stackoverflow.com/questions/8746207/1071-specified-key-was-too-long-max-key-length-is-1000-bytes https://stackoverflow.com/questions/40109903/1071-specified-key-was-too-long-max-key-length-is-1000-bytes – Isma Aug 23 '17 at 12:08

1 Answers1

1
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql("SET default_storage_engine=INNODB");
}

Ability to specify engine, charset, ROW_FORMAT and more