EF Migrations can't seem to detect my changes to the model, as it just generates an empty Up() / Down()
when running Add-Migration
.
The database is not out of sync with my migrations.
Migration file:
__migrationhistory table:
Before
public class House {
public virtual ICollection<Person> UsedBy { get; set; }
}
public class Car {
// ...
}
public class Person {
public int? UsingId { get; set; }
public virtual House Using { get; set; }
}
Mapping
this.HasOptional(t => t.Using)
.WithMany(t => t.UsedBy)
.HasForeignKey(t => t.UsingId);
After
public class House {
// removed
}
public class Car {
// added
public virtual ICollection<Person> UsedBy { get; set; }
}
public class Person {
public int? UsingId { get; set; }
// changed type
public virtual Car Using { get; set; }
}
Mapping
this.HasOptional(t => t.Using)
.WithMany(t => t.UsedBy)
.HasForeignKey(t => t.UsingId);