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
2 Answers
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.
-
-
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 runRemove-Migration
multiple times, then start over again withAdd-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
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