I am using Package Manager Console to add migrations to my database and for some reason it just freezes and does nothing. The only way to stop it and continue using it is to close down Visual Studio using the Task Manager. Is this a known issue?
add-migration : The term 'add-migration' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Add-Migration: Creates a new migration class as per specified name with the Up() and Down() methods. Update-Database: Executes the last migration file created by the Add-Migration command and applies changes to the database schema.
Add-Migration Adds a new migration. Remove-Migration Removes the last migration. Scaffold-DbContext Scaffolds a DbContext and entity type classes for a specified database. Script-Migration Generates a SQL script from migrations.
Delete your Migrations folder. Create a new migration and generate a SQL script for it. In your database, delete all rows from the migrations history table. Insert a single row into the migrations history, to record that the first migration has already been applied, since your tables are already there.
I'm not sure if this is a known issue, but I had the same problem, and found a solution for it.
I had to run:
Enable-Migrations -ContextTypeName MyContext -ProjectName MyProject.Framework -StartUpProjectName MyProject.Web
Where I specified:
-ContextTypeName
as the name of my context-ProjectName
as the project that held my Context file-StartUpProjectName
as the project that held the web application.You can reference this resource for more information: http://coding.abel.nu/2012/03/ef-migrations-command-reference/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With