Generate new Migrations based on all models

Asked

Viewed 170 times

6

I need to create an Migrations with all the models created (I ended up deleting the first Migration and I am not able to create the authentication database).

  • If you try to create again using the command Add-Migration NomeDaMigration and even then it does not generate, so if you can (check before if you do not have confidential data that cannot be lost for example), one option is to delete the database and then run the command Update-Database. Done this you try to generate again with the command Add-Migration NomeDaMigration. In case this resolves I insert as answer :-)

  • Does not solve. It continues to generate a new Migration, but empty.

1 answer

4


If only the migration has been deleted(still with Modelsnapshot and the base still created):

delete the Modelsnapshot and ALL migration-related files (*.Designer.Cs and *.resx)(in the Migrations folder) and run the Add-Migration with the same name as the previous migration(to ensure that, in the database in which the migration has already been run, the system does not attempt to create the whole structure again, if you have doubts about the migration name, select in the "__Efmigrationshistory" table in the bank where this migration has already been run and look at its name, it is useful to change the name of the migration class created so that it is IDENTICAL to the name in this table).

  • No Modelsnapshot in Migrations folder.

  • And yet Add-Migration keeps generating empty?

  • if yes, could clean run a delete in the table "__Efmigrationshistory" (can be of all the same data) and try again?

  • I have already done these procedures. Continue to generate an empty Migration.

  • You could open your "Migrations" folder in the explorer and tell me which files are in it?

  • http://prntscr.com/l1gozb

  • 1
Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.