![]() We can enable the automatic migration through the following command –Įnable-migrations –EnableAutomaticMigration:$true ![]() If we want to see the SQL statements our migration process applied to the database, we can use -verbose parameter with the update-databaseĪutomated Migration – In this type of migration we don’t have to process the migration manually for every change. Rollback Migration – If we want to rollback our database schema to any previous migration state then we can use the update-database command with the -TargetMigration parameter. The Up() function contains the code for creating the database and Down() function contains the code for dropping or deleting the database objects.įor help with any command, we can execute a command get-help Up and down functions in the migration file Update-database – This command will execute the last migration created by the add-migration command.This command will create a new file with _.cs Add-migration – It adds all the changes in the models in the up and down functions in the new migration file.Enable-migration – This command enables the migration for our project by creating the Migration folder and Configuration class.There are 2 ways to do the migration in code first –Ģ.Automated Migration Code-based Migrationįor code migration, we need to use the following commands in the Nuget Package manager console in visual studio – Initially, we need to create the domain classes having the properties and then we create the database according to the domain classes.ĭatabase Migration – Migration is used to update the database schema as our domain classes change. In code first approach we create the domain classes first rather than creating the database.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |