I have a web application that I install on my clients' computers for internal use. I am using C # MVC5 and Code Entity Framework. I used automatic migration = true, but I stopped and set it to false. I installed it in a production environment (release) - with the deploy-package (without Visual Studio).
I have a client with the application - version 1. Now I want to switch to version 2. I want to enable updating the application database (in a working file, installing CMD from the package), but in order to be able to lower the database if there are any problems, but without deleting existing rows.
For example, if I have a table called βElementsβ and the elements have Key, Name, Location . When updating, I add a new column: Email . When downgraded, the new column will be deleted. I created a migration in Visual Studio. I get this code (this is just for example - I have more migrations):
public partial class AddEmail : DbMigration { public override void Up() { AddColumn("dbo.Items", "Email", c => c.String()); } public override void Down() { DropColumn("dbo.Items", "Email"); } }
Now I installed the new version of the application into the existing version, and it worked fine - a new column was added and it worked with the new code. I have added a few elements (rows).
Now, how can I reinstall the old version so that the new column is deleted? Actually I want to undo new migrations, but I do not want to lose new rows, only new columns.
c # ef-code-first code-first-migrations downgrade
Tamarg
source share