title: Identity Entity Framework Library - Update Database [MySQL]
body: <p>I just updated the library Microsoft.AspNet.Identity.EntityFramework to the last version (2.0.0.0) and I have found some errors creating the tables. When I generate the migration code (Up and Down methods), I can't upload the changes to the database beacuse of I have a problem with indexs when I execute the "Updata-Database" </p>
  
  <blockquote>
    <p>Specified key was too long; max key length is 767 bytes</p>
  </blockquote>
  
  <p>Code to execute:</p>
  
  <pre><code>public override void Up()
      {
          CreateTable(
              "dbo.AspNetRoles",
              c =&gt; new
                  {
                      Id = c.String(nullable: false, maxLength: 128, storeType: "nvarchar"),
                      Name = c.String(nullable: false, maxLength: 256, storeType: "nvarchar"),
                  })
              .PrimaryKey(t =&gt; t.Id)
              .Index(t =&gt; t.Name, unique: true, name: "RoleNameIndex");
  
          CreateTable(
              "dbo.AspNetUserRoles",
              c =&gt; new
                  {
                      UserId = c.String(nullable: false, maxLength: 128, storeType: "nvarchar"),
                      RoleId = c.String(nullable: false, maxLength: 128, storeType: "nvarchar"),
                  })
              .PrimaryKey(t =&gt; new { t.UserId, t.RoleId })
              .ForeignKey("dbo.AspNetRoles", t =&gt; t.RoleId, cascadeDelete: true)
              .ForeignKey("dbo.AspNetUsers", t =&gt; t.UserId, cascadeDelete: true)
              .Index(t =&gt; t.UserId)
              .Index(t =&gt; t.RoleId);
  
          CreateTable(
              "dbo.AspNetUsers",
              c =&gt; new
                  {
                      Id = c.String(nullable: false, maxLength: 128, storeType: "nvarchar"),
                      Email = c.String(maxLength: 256, storeType: "nvarchar"),
                      EmailConfirmed = c.Boolean(nullable: false),
                      PasswordHash = c.String(maxLength: 256, storeType: "nvarchar"),
                      SecurityStamp = c.String(maxLength: 256, storeType: "nvarchar"),
                      PhoneNumber = c.String(maxLength: 256, storeType: "nvarchar"),
                      PhoneNumberConfirmed = c.Boolean(nullable: false),
                      TwoFactorEnabled = c.Boolean(nullable: false),
                      LockoutEndDateUtc = c.DateTime(precision: 0),
                      LockoutEnabled = c.Boolean(nullable: false),
                      AccessFailedCount = c.Int(nullable: false),
                      UserName = c.String(nullable: false, maxLength: 256, storeType: "nvarchar"),
                  })
              .PrimaryKey(t =&gt; t.Id)
              .Index(t =&gt; t.UserName, unique: true, name: "UserNameIndex");
  
          CreateTable(
              "dbo.AspNetUserClaims",
              c =&gt; new
                  {
                      Id = c.Int(nullable: false, identity: true),
                      UserId = c.String(nullable: false, maxLength: 128, storeType: "nvarchar"),
                      ClaimType = c.String(maxLength: 256, storeType: "nvarchar"),
                      ClaimValue = c.String(maxLength: 256, storeType: "nvarchar"),
                  })
              .PrimaryKey(t =&gt; t.Id)
              .ForeignKey("dbo.AspNetUsers", t =&gt; t.UserId, cascadeDelete: true)
              .Index(t =&gt; t.UserId);
  
          CreateTable(
              "dbo.AspNetUserLogins",
              c =&gt; new
                  {
                      LoginProvider = c.String(nullable: false, maxLength: 128, storeType: "nvarchar"),
                      ProviderKey = c.String(nullable: false, maxLength: 128, storeType: "nvarchar"),
                      UserId = c.String(nullable: false, maxLength: 128, storeType: "nvarchar"),
                  })
              .PrimaryKey(t =&gt; new { t.LoginProvider, t.ProviderKey, t.UserId })
              .ForeignKey("dbo.AspNetUsers", t =&gt; t.UserId, cascadeDelete: true)
              .Index(t =&gt; t.UserId);
  
      }
  
      public override void Down()
      {
          DropForeignKey("dbo.AspNetUserRoles", "UserId", "dbo.AspNetUsers");
          DropForeignKey("dbo.AspNetUserLogins", "UserId", "dbo.AspNetUsers");
          DropForeignKey("dbo.AspNetUserClaims", "UserId", "dbo.AspNetUsers");
          DropForeignKey("dbo.AspNetUserRoles", "RoleId", "dbo.AspNetRoles");
          DropIndex("dbo.AspNetUserLogins", new[] { "UserId" });
          DropIndex("dbo.AspNetUserClaims", new[] { "UserId" });
          DropIndex("dbo.AspNetUsers", "UserNameIndex");
          DropIndex("dbo.AspNetUserRoles", new[] { "RoleId" });
          DropIndex("dbo.AspNetUserRoles", new[] { "UserId" });
          DropIndex("dbo.AspNetRoles", "RoleNameIndex");
          DropTable("dbo.AspNetUserLogins");
          DropTable("dbo.AspNetUserClaims");
          DropTable("dbo.AspNetUsers");
          DropTable("dbo.AspNetUserRoles");
          DropTable("dbo.AspNetRoles");
      }
  </code></pre>
  
  <p>When I use the versión 1.0.0.0 of Microsoft.AspNet.Identity.EntityFramework the code to update the database is different and I don't have any problem</p>
  
  <pre><code>public override void Up()
      {
          CreateTable(
              "dbo.AspNetRoles",
              c =&gt; new
                  {
                      Id = c.String(nullable: false, maxLength: 128, storeType: "nvarchar"),
                      Name = c.String(nullable: false, maxLength: 256, storeType: "nvarchar"),
                  })
              .PrimaryKey(t =&gt; t.Id);
  
          CreateTable(
              "dbo.AspNetUsers",
              c =&gt; new
                  {
                      Id = c.String(nullable: false, maxLength: 128, storeType: "nvarchar"),
                      UserName = c.String(maxLength: 256, storeType: "nvarchar"),
                      PasswordHash = c.String(maxLength: 256, storeType: "nvarchar"),
                      SecurityStamp = c.String(maxLength: 256, storeType: "nvarchar"),
                      Discriminator = c.String(nullable: false, maxLength: 128, storeType: "nvarchar"),
                  })
              .PrimaryKey(t =&gt; t.Id);
  
          CreateTable(
              "dbo.AspNetUserClaims",
              c =&gt; new
                  {
                      Id = c.Int(nullable: false, identity: true),
                      ClaimType = c.String(maxLength: 256, storeType: "nvarchar"),
                      ClaimValue = c.String(maxLength: 256, storeType: "nvarchar"),
                      User_Id = c.String(nullable: false, maxLength: 128, storeType: "nvarchar"),
                  })
              .PrimaryKey(t =&gt; t.Id)
              .ForeignKey("dbo.AspNetUsers", t =&gt; t.User_Id, cascadeDelete: true)
              .Index(t =&gt; t.User_Id);
  
          CreateTable(
              "dbo.AspNetUserLogins",
              c =&gt; new
                  {
                      UserId = c.String(nullable: false, maxLength: 128, storeType: "nvarchar"),
                      LoginProvider = c.String(nullable: false, maxLength: 128, storeType: "nvarchar"),
                      ProviderKey = c.String(nullable: false, maxLength: 128, storeType: "nvarchar"),
                  })
              .PrimaryKey(t =&gt; new { t.UserId, t.LoginProvider, t.ProviderKey })
              .ForeignKey("dbo.AspNetUsers", t =&gt; t.UserId, cascadeDelete: true)
              .Index(t =&gt; t.UserId);
  
          CreateTable(
              "dbo.AspNetUserRoles",
              c =&gt; new
                  {
                      UserId = c.String(nullable: false, maxLength: 128, storeType: "nvarchar"),
                      RoleId = c.String(nullable: false, maxLength: 128, storeType: "nvarchar"),
                  })
              .PrimaryKey(t =&gt; new { t.UserId, t.RoleId })
              .ForeignKey("dbo.AspNetRoles", t =&gt; t.RoleId, cascadeDelete: true)
              .ForeignKey("dbo.AspNetUsers", t =&gt; t.UserId, cascadeDelete: true)
              .Index(t =&gt; t.UserId)
              .Index(t =&gt; t.RoleId);
  
      }
  
  
  
      public override void Down()
      {
          DropForeignKey("dbo.AspNetUserRoles", "UserId", "dbo.AspNetUsers");
          DropForeignKey("dbo.AspNetUserLogins", "UserId", "dbo.AspNetUsers");
          DropForeignKey("dbo.AspNetUserClaims", "UserId", "dbo.AspNetUsers");
          DropForeignKey("dbo.AspNetUserRoles", "RoleId", "dbo.AspNetRoles");
          DropIndex("dbo.AspNetUserLogins", new[] { "UserId" });
          DropIndex("dbo.AspNetUserClaims", new[] { "UserId" });
          DropIndex("dbo.AspNetUsers", "UserNameIndex");
          DropIndex("dbo.AspNetUserRoles", new[] { "RoleId" });
          DropIndex("dbo.AspNetUserRoles", new[] { "UserId" });
          DropIndex("dbo.AspNetRoles", "RoleNameIndex");
          DropTable("dbo.AspNetUserLogins");
          DropTable("dbo.AspNetUserClaims");
          DropTable("dbo.AspNetUsers");
          DropTable("dbo.AspNetUserRoles");
          DropTable("dbo.AspNetRoles");
      }
  </code></pre>
  
  <p>Can anyone help me try to solve the problem?</p>
  
  <p>Thanks in advance!!</p>