Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Upgrading from 11.0 to 11.2 with mysql - How to address migrations? #11136


User avatar
0
marble68 created

Prerequisites

MVC Core version 11.2 Jquery

Status

I have an 11.0 project, and I've merged in 11.2. Everything looks good - but there are new migrations for things like previous passwords ect.

Also - the entity framework versions are different.

Since I'm using mysql, I need to regenerate these migrations and migrate my existing database.

What I tried was merging in my upgraded branch into my existing dev branch without the migration files.

However - I've not been successful at applying the changes.

Firstly, add-migration and update-database return there there is more than one dbcontext and I must specify. When I do, it still does not like the migrations generated.

What is the normal process for this? Am I missing something?

Thanks!


3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @marble68

    If you are using MySql, you need to ignore Migrations folder under EFCore project and add a new migration when the upgrade operation is completed. Then, you can apply changes to your database. You can specify the DbContext name when using add-migration and update-database commands.

  • User Avatar
    0
    marble68 created

    Thank you for the response. Yes, I'm seeing that I have to do that in 11.2. The heathchecker context requires -context since it, too, is a dbcontext.

    My deeper question is around those migrations. After merging 11.2 into my 11.0 project, I have existing migrations and need to add another for the changes in 11.2.

    So, I then added a new one, to pick up the new tables (such as password history, etc).

    The end result would not apply, and it ended up trying to add a bunch of foreign keys that already existed.

    Is this the normal workflow? At this point, I am supposed to edit the new migration to make it compatible with my project?

    Sorry if this is a dumb question - but I'm strugging to find the "best practice" for this. I will eventually have to figure it out because I can't just wipe out my database every time I update my project.

    I'm just not clear on what's required. If editing the migration manually is required, I suppose that will be what I'll have to do.

  • User Avatar
    0
    marble68 created

    I did indeed have to create an entirely new repository.

    Only then did my migrations seem to behave better.

    Thank you.