I have a local database that is currently in it\'s second version and should now go to it\'s third version.
The code for the previous migrations was generated by ano
I had this problem because I forgot to add {get; set;} after my variable names
I think this also happens when u try to do migration without any changes in the models. eg when you do migration one and succeed, when u try to do migration2 without doing any changes in any of the models, it will create empty UP and Down.
In my case I was doing a migration where I added fields to an existing table and was ending up with empty Up
and Down
methods,
I had something like this:
public bool ExistingField { get; set; }
bool NewField { get;set; }
Can you spot the difference...?
If you make this mistake rerun the migration with the same name (you probably will need to add the -Force
parameter to scaffold it full).
PS. Always make sure your project builds fully before attempting to do any kind of EF command. If your project doesn't already build you're asking for trouble.
You need to add your table to your implementation of the DbContext
class, e.g.
public class MyDatabaseEntities : DbContext {
public virtual DbSet<MyTable> MyTable { get; set; }
}
While rolling back an existing EF Core Data Context back to empty, my migrations wouldn't generate until I removed the ApplicationDbContextModelSnapshot
that accompanied the migrations.
This class is auto-generated and needs to align with your current migration level.