This article is rather small, but its target is to remind me how to enable migrations of database in Visual Studio.
Thus, the steps are:
- Press Ctrl + Q to go to the quick launch.
- In the quick launch write “Package Manager Console” and press enter.
- Make sure that you have selected the correct Default project in the console.
- In the console write> Enable-Migrations -EnableAutomaticMigrations and press enter.
- In the solution explorer, you get a folder migrations, in which a file Configuration.cs is present.
- If you open it, you may configure it this way (just an example, do not ever do AutomaticMigrationDataLossAllowed = true in production):
1 2 3 4 5 6 |
public Configuration() { AutomaticMigrationDataLossAllowed = true; this.AutomaticMigrationsEnabled = true; this.ContextKey = "ForumSystem.Data.ForumContext"; } |
And that is it!