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

Running initial migrations against MySQL #12048


User avatar
0
Abaco created

We just licensed ASP.NET Zero for a new project and configured it to use a MySQL db as documented but when trying to run the existing migrations that ship with the project either using the Migrator project, package manager console or the dotnet cli (with the ef addon) we get errors that the syntax and data types being used on the existing migrations is not compatible with MySQL since they seem to have been coded for SQL Server. Examples: datetime2, nvarchar(max), varbinary(max) to name a few.

Is there an easier way other than modifying all of those migrations to be MySQL compatible to get the initial set of entities, indexes, etc created for a project?


5 Answer(s)
  • User Avatar
    0
    m.aliozkaya created
    Support Team

    Hi @Abaco,

    I suggest you delete all migrations and create an initial migration for MySQL.

  • User Avatar
    0
    Abaco created

    Ok, just did and the migration that gets created isn't a valid one. It starts with dropping FK constraints that dont even exist since the db is empty:

  • User Avatar
    0
    Abaco created

    Ok, I missed one important piece of information from the instructions:

    Remove all migration classes (including DbContextModelSnapshot) under *.EntityFrameworkCore/Migrations folder;

  • User Avatar
    0
    Abaco created

    Hello there. We noticed after doing this even though it worked to create the initial migration and update the database correctly, when we run add-migration to create a new one with changes we're doing to the model, the new migration gets created with all of the same structures that the initial migration already created causing duplication errors. Any ideas why it's not doing the "diff" to create only the new changes?

  • User Avatar
    0
    m.aliozkaya created
    Support Team

    Hi @Abaco,

    Could you share your project with [email protected]