EF add-migration generates empty migration

I added a new table to my model:

public DbSet<ReturnedTransactions> ReturnedTransactions { get; set; } 

And I want my migrations to create this table for me, so I did:

 PM> Add-migration returnedTransactions 

And he generated

 public partial class returnedTransactions : DbMigration { public override void Up() { } public override void Down() { } } 

How to make this thing generate the right code for me?

+7
source share
3 answers

Clear the _MigrationHistory table.

+1
source

I see this happening when I do not add my DBSet to my DbContext class, which is associated with the migration configuration file.

Although, perhaps this is not so, since we see that Asker has included the line:

 public DbSet<ReturnedTransactions> ReturnedTransactions { get; set; } 

However, this is what you need to check when an empty migration class is returned.

+1
source

I had this problem and I added -Force to the Add-Migration team and it worked.

0
source

All Articles