We\'re using Entity Framework 5.0 Code First and Automatic Migrations.
I had a class like so:
public class TraversalZones
{
public int Low { get;
The workaround, obviously, is this:
update-database -f -script
Which you can see the results of in my question. Then I tossed everything from the script but the last line, and ran that against the DB to let Migrations know: We already renamed that column, cut it out.
I can now proceed with this copy of the database, but I'm concerned every migration against copies of Production (until Production itself has been migrated) will keep having this issue. How can I resolve this properly without this workaround?
Update
This was in fact an issue in every other instance including Production. The dirty solution was to generate a SQL script (update-database -f -script
), after committing the generated version and the fixed version.
A slightly cleaner solution is to take the SQL from the script, add a manual migration, and change the contents of Up to simply:
public void Up()
{
Sql("...That SQL you extracted from the script...");
}
This will ensure other environments running this migration do so precisely the way you intended.
Testing this is a bit tricky so you can approach it this way:
Sql("...");
calling the SQL you set aside.Now your db is up to date without running the SQL twice, and other environments get the results of that SQL.