Search⌘ K
AI Features

Challenge Solution: Migrations

Explore how to manage schema modifications in Entity Framework Core by renaming and deleting entity properties. Learn to create migrations that reflect these changes and generate SQL scripts for updating live databases. This lesson helps you maintain database consistency and control changes safely during development.

Overview

We’ll solve the challenge using the project below.

{
    "version": "0.2.0",
    "configurations": [
        {
            // Use IntelliSense to find out which attributes exist for C# debugging
            // Use hover for the description of the existing attributes
            // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
            "name": ".NET Core Launch (console)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            // If you have changed target frameworks, make sure to update the program path.
            "program": "${workspaceFolder}/bin/Debug/net6.0/CodeFirst.dll",
            "args": [],
            "cwd": "${workspaceFolder}",
            // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
            "console": "internalConsole",
            "stopAtEntry": false
        },
        {
            "name": ".NET Core Attach",
            "type": "coreclr",
            "request": "attach"
        }
    ]
}
Migrations challenge

Click the “Run” button of the SPA widget above, and then execute the command below in the terminal:

C#
dotnet ef migrations add RenameAndDeletePropertiesInDept
...