I have here an issue with AspNet Identity and MySql, the issue is error which is really blocking me, this error is following:
specified key was too long max key length is 767 bytes
Now I followed this tutorial of using MySql with Identity:
http://www.asp.net/mvc/tutorials/security/aspnet-identity-using-mysql-storage-with-an-entityframework-mysql-provider
I want to say I had progression, because now atleast i get some tables generated in MySQL, but I'm stack on this issue, for a long time i'm trying to solve this, but without success.
The error i get is in this part:
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<int>(
string.Format(
"SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '{0}' AND table_name = '__MigrationHistory'",
"Server=127.0.0.1;Database=mydb;uid=root;pwd=mypass;port=3351;"));
// 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(); //<<<< i get here error
}
}
}
So this throws error : context.Database.Create();
I tried to investigate what exactly is the problem but i couldn't find :(
I tried comparing the data in sql server generated database and put the same info in the migrationtable, and normally i can put the same values in there from insert statement in workbench.
Maybe anyone can help me to get through this?
Just to notice, at the end all of the tables are created but nothing is inserted, because of the error :/
Here are all the tables that are created in mysql schema:
I have a small update: It seems that it tries to make a combined PK from the 2 columns migrationId and contextkey, that is why you get this kind of error.
I could reproduce it in my workbench i tried to alter table, by setting those columns as PK's and i got exactly the same error. But how do I say that only 1 PK should be set for example?