Created
October 10, 2025 00:23
-
-
Save ChrisMoney/f685ff47d67529df1c4f28c08cd5e37d to your computer and use it in GitHub Desktop.
Migration Commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add a new migration | |
Add-Migration <MigrationName> -Project AdamsTax.Modules.API -StartupProject AdamsTax.Modules.API | |
Add-Migration AD-853-AddsAccessCodeTables -Project AdamsTax.Modules.API -StartupProject AdamsTax.Modules.API | |
In Visual Studio, go to Tools > NuGet Package Manager > Package Manager Console. | |
Add-Migration AD-853_AddPrintingAccessRelationships -Project AdamsTax.Modules.API -StartupProject AdamsTax.Modules.API -Context ApiDataContext | |
# Update the database to the latest migrationfrom the Package Manager Console | |
- Run from inside Visual Studio and have the src\Modules\API\AdamsTaxAPI project selected in the Default project drop down list. | |
- Then run this command: | |
$env:ASPNETCORE_ENVIRONMENT='Local'; Update-Database -Project MyProject.API -StartupProject MyProject.API -Context ApiDataContext | |
# Remove the last migration (if not yet applied to the database) | |
Remove-Migration -Project MyProject.API -StartupProject MyProject.API | |
# List all migrations | |
Get-Migration -Project MyProject.API -StartupProject MyProject.API | |
# Generate a SQL script for migrations | |
Script-Migration -From <FromMigration> -To <ToMigration> -Project MyProjectAPI -StartupProject MyProjectAPI | |
Migration Template: | |
migrationBuilder.Sql(@" | |
UPDATE YourTableName | |
SET ColumnName = 'NewValue' | |
WHERE SomeCondition = 1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment