![]() The Up() method uses MigrationBuilder to create and manage database objects such as creating tables and adding/ removing columns based on the model. ![]() The Initial class has two methods Up() and Down(). ![]() Typically, the class name is the same as the migration name, which is Initial in this example. The migration file defines a partial class that extends the Migration class. The Migrations directory has two files:Ģ0230608062832_Initial.cs – it starts with a timestamp and is followed by the migration name. If you view the HR project, you’ll see the Migrations directory created. To undo this action, use Remove-Migration. The command will return the following output, indicating that the migration has been created successfully: Build started. The minimal requirement of the Add-Migration command is a migration name.įor example, the following creates a new migration called Initial: Add-Migration Initial Code language: plaintext ( plaintext ) To create a migration, you use the Add-Migration command. To get help on a specific command, you pass that command to the Get-Help command like this: Get-Help commandįor example, you can use the Get-Help command to display the help for the Add-Migration command: get-help add-migration Code language: JavaScript ( javascript ) The Get-Help command shows all the commands available in Entity Framework Core. It’ll show the following output (excerpt): To view all available commands, you execute the following help command in the Package Manager Console (PMC): get-help entityframework Code language: JavaScript ( javascript ) Once having the packaged install, you’re ready to explore the migration commands. Note that before running the migration commands, you need to install the package from NuGet Package.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |