We wish to get rid of 100s of migration classes as DB schema in production is final.
Here are the steps I followed:
- Delete Migrations folder.
- Add-Migration -??
What command line switches, could help us?
EDIT:
If all goes well Up() method of migration should be empty right? For example following is wrong generation on Add-Migration. Because if we execute the project we will get duplicate table errors.
public partial class Sanity : DbMigration
{
public override void Up()
{
CreateTable(
"dbo.AccountPreferences",
c => new
{
AccountID = c.Guid(nullable: false),
}
.... for 1000s of tables
}
}
A clean migration would be something: when trying Add-Migration
on subsequent changes, should not be getting any error.
Unable to generate an explicit migration because the following explicit migrations are pending: [201712281054591_Sanity]. Apply the pending explicit migrations before attempting to generate a new explicit migration.
As you can see if we happen to execute Update-Database
will get table already exist error.
Are we forced to always retains all migration copies?