I am trying to generate a migration using code first approach. i generate the migration with the command :
add-migration -ConfigurationTypeName [FullyQualifiedConfigurationClass] [MigrationFile Name]
The Migration is generated successfully but it has code for previously deleted models from Models directory.
Here is a snippet of the migration code that shows table creation code for a model that i already deleted.
CreateTable(
"dbo.PlaylistMovies",
c => new
{
Playlist_Id = c.Int(nullable: false),
Movie_Id = c.Int(nullable: false),
})
.PrimaryKey(t => new { t.Playlist_Id, t.Movie_Id })
.ForeignKey("dbo.Playlists", t => t.Playlist_Id, cascadeDelete: true)
.ForeignKey("dbo.Movies", t => t.Movie_Id, cascadeDelete: true)
.Index(t => t.Playlist_Id)
.Index(t => t.Movie_Id);
);
What did I try and didn't work ?
- changed the database context class name
- changed the database name in context constructor
- change the migration name over and over