Error when connecting MySQL from Entity Framework
<p>I am following this <a href="http://www.asp.net/identity/overview/getting-started/aspnet-identity-using-mysql-storage-with-an-entityframework-mysql-provider" rel="nofollow">tutorial</a> to create a mvc application connecting to mysql and getting this error.</p>

<blockquote>
  <p>An exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll but was not handled in user code, Additional information: Specified key was too long; max key length is 1000 bytes</p>
</blockquote>

<p>I followed everything from the tutorial apart from my mysql database is on godaddy rather than on azure. New database and new MVC Application in VS2013 .Net 4.5.1. EF 6.1.3 and MySQL.Data.Entity version is 6.9.8.</p>

<p>The error is on this line.</p>

<p><strong>context.Database.Create();</strong></p>

<p>I found some people got same problem but their solution isn't using SetInitializer like in this tutorial. I hope some one can point out what I'm doing wrong.</p>

<pre><code>public class MySqlInitializer : IDatabaseInitializer&lt;ApplicationDbContext&gt;
    {

        public void InitializeDatabase(ApplicationDbContext context)
        {
            if (!context.Database.Exists())
            {
                // if database did not exist before - create it
                context.Database.Create();
            }
            else
            {
                // query to check if MigrationHistory table is present in the database 
                var migrationHistoryTableExists = ((IObjectContextAdapter)context).ObjectContext.ExecuteStoreQuery&lt;int&gt;(
                string.Format(
                  "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '{0}' AND table_name = '__MigrationHistory'", "users"));

                // if MigrationHistory table is not there (which is the case first time we run) - create it
                if (migrationHistoryTableExists.FirstOrDefault() == 0)
                {
                    context.Database.Delete();
                    context.Database.Create();
                }
            }
        }
    }

 public class MySqlHistoryContext : HistoryContext
{
    public MySqlHistoryContext(
              DbConnection existingConnection,
              string defaultSchema)
        : base(existingConnection, defaultSchema)
    {
    }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        base.OnModelCreating(modelBuilder);
        modelBuilder.Entity&lt;HistoryRow&gt;().Property(h =&gt; h.MigrationId).HasMaxLength(100).IsRequired();
        modelBuilder.Entity&lt;HistoryRow&gt;().Property(h =&gt; h.ContextKey).HasMaxLength(200).IsRequired();
    }
}

public class MySqlConfiguration : DbConfiguration
{
    public MySqlConfiguration()
    {
        SetHistoryContext(
        "MySql.Data.MySqlClient", (conn, schema) =&gt; new      MySqlHistoryContext(conn, schema));
    }
}

public class ApplicationUser : IdentityUser
    {
        public async Task&lt;ClaimsIdentity&gt; GenerateUserIdentityAsync(UserManager&lt;ApplicationUser&gt; manager)
        {
            // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
            var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
            // Add custom user claims here
            return userIdentity;
        }
    }

    public class ApplicationDbContext : IdentityDbContext&lt;ApplicationUser&gt;
    {
        static ApplicationDbContext()
        {
            Database.SetInitializer(new MySqlInitializer());
        }

    public ApplicationDbContext()
        : base("DefaultConnection", throwIfV1Schema: false)
    {
    }

    public static ApplicationDbContext Create()
    {
        return new ApplicationDbContext();
    }
}
</code></pre>