Base solution for your next web application
Open Closed

Migrator Tool not working correctly #1673


User avatar
0
kythor created

I just updated the User entity with some custom profile fields. I have done this before without problems. Add-Migration, Update-Database and after that start the Migrator to update the tenant databases.

But now suddenly when using the Migrator I get an error saying there are still Pending Changes. But there aren't. The host database contains the new fields.

What am I missing here?


6 Answer(s)
  • User Avatar
    0
    kythor created

    It must have something to do when I first added the last modification, I forgot to actually change the entity. Did not yet used Update-Database. I changed the entity, and used Add-Migration "" -force, using the same migration name. Update-Databse works, but nog migrator.

    Now I added an empty migration again, update-database, and the migrator works. But now the new fields of the previous migration are not added to the tenant db.

    now what?

  • User Avatar
    0
    kythor created

    Now I reverted the last 2 migrations, effectifly removing the new fields from the host database. everytime running Migrator to be sure the tenant db's are on the same version.

    When re-adding the migration to add the fields, they are added to the host db. Running Migrator now without problems, but the fields are NOT added to the tenant db.....

  • User Avatar
    0
    hikalkan created
    Support Team

    EF's migration system is so sensitive. You shouldn't do changes in migration class after update-database command. If you need, you should add another migration. And also, even you delete the migration files and revert changes manually in database, you should also remove related rows from __MigrationHistory table before adding a new migration or running update-database.

  • User Avatar
    0
    kythor created

    thanks for the info. I will try your suggestion.

  • User Avatar
    0
    kythor created

    while debugging, whenever I try to login with a user from the separate tenant db, I get this error:

    'The underlying provider failed on Open'

    why?

    I have added the fields to the tenant db that were missing. And in production everything works fine. But when I'm debugging, I get this error

  • User Avatar
    0
    hikalkan created
    Support Team

    This error is not related to migrations but a problem with database connection. Be sure that the database connection is true and the database is available. Please double check it since this is not related to AspNet Zero, but a simple .NET exception.