0

I'm tried to Add-Migration in my asp.net core application but migration not working Please any one give me ans for this what's the issue

Please check this image i added all information reading issue everything i combined into single screen-shot for more clarification

2 Answers 2

0

you need to provide a name for the migration just like this Add-Migration V1, after creating the migration you need to run the Update-Database to apply the migration. BTW if there is any build error nothing will work. you need to ensure there is not build error.

6
  • I added name Intial but not working showing stack overflow Feb 6, 2020 at 17:43
  • I added name Initial but not working showing me stack overflow There is no any build error everything is fine application is running In package-console window also showing Build succeeded. Feb 6, 2020 at 17:49
  • if you have any existing migration delete them all using Remove-Migration if you have multiple migration then you need to run Remove-Migration multiple times, then start over again with Add-Migration Feb 6, 2020 at 17:54
  • There is no any existing migration i deleted all folder with Migration name also deleted table from Database .I don't know whats the problem in this why not working for me doing all these things. Feb 6, 2020 at 17:59
  • here is the check list you need to check: 1. you have a correct database connection, 2. You have a entity, 3. go through the migrations steps starting with Add-Migration. Feb 6, 2020 at 18:03
0

I would do this:

1) Remove the Migrations folder in your project

2) Delete the _MigrationHistory table from your database.

3) Run the Enable-Migrations command from your Package Manager Console.

4) Run the Add-Migration Init command to create a migration.

5) Remove all of the code lines in Up() function for the initial migration. (To create an empty migration.)

6) Run the Update-Database command to apply your empty migration.

7) Make changes to your code first model for preparing to adding your real migration.

8) Run the Add-Migration InitNew command to create a new migration.

9)Run the Update-Database command to apply the changes.

Taken from: https://stackoverflow.com/a/44019743/6221069

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.