Results 1 to 5 of 5

Threaded View

  1. #1
    Join Date
    Feb 2014

    Entity Framework - rolling back a change with a pivot table

    When I was doing the MMO course the first ever migration had a pivot table in it.
    Subsequent changes to the database never involved a pivot table, just modifying a table or adding a new table.

    Here's the problem - I get an error trying to rollback any change that involves a pivot table. Never have a problem with just a table mod or a new table.

    Here's an example of the Down method from the very first commit in the MMO course:
            public override void Down()
                DropForeignKey("dbo.UserRoles", "Role_Id", "dbo.Roles");
                DropForeignKey("dbo.UserRoles", "User_Id", "dbo.Users");
                DropIndex("dbo.UserRoles", new[] { "Role_Id" });
                DropIndex("dbo.UserRoles", new[] { "User_Id" });
    When rolling back the database with

    update-database -TargetMigration:0 -verbose
    I get an error that according to all the google searches seems to be a fairly vague error caused by any number of things.

    alter table `dbo.UserRoles` drop foreign key `FK_dbo.UserRoles_dbo.Roles_Role_Id`
    System.Runtime.Serialization.SerializationException: Type is not resolved for member 'MySql.Data.MySqlClient.MySqlException,MySql.Data, Version=, Culture=neutral, PublicKeyToken=c5687fc88969c44d'.
       at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
       at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
       at System.Data.Entity.Migrations.Design.ToolingFacade.Update(String targetMigration, Boolean force)
       at System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0()
       at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
    Type is not resolved for member 'MySql.Data.MySqlClient.MySqlException,MySql.Data, Version=, Culture=neutral, PublicKeyToken=c5687fc88969c44d'.
    In other words it falls at the first hurdle with a 'type is not resolved' error.

    Now it never mattered in the MMO course, but I am currently adding the Post and Tag tables from the SimpleBlog series and I really hate to have a migration that I cannot rollback.

    Tried a lot of things, but nothing's worked so far. Since I'm running out of ideas I thought I would post here just in case there is something simple.

    By the way, deleting the foreign keys, indexes and tables work fine in MySQL workbench.
    ALTER TABLE `dev_buzzmmo`.`userroles` 
    DROP FOREIGN KEY `FK_UserRoles_Roles_Role_Id`;
    Last edited by oldngrey; 02-23-2017 at 11:10 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts