Search⌘ K

Challenge: Migrations

Explore how to update and manage data models in Entity Framework Core through practical migration tasks. Learn to rename properties, remove fields, create migrations, and generate SQL scripts to deploy changes efficiently to a live database. This lesson provides hands-on experience handling schema updates and producing scripts essential for real-world application deployment.

We'll cover the following...

Overview

Using the project below, perform the tasks described in the requirements section.

{
    "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"
        }
    ]
}
Challenge on migrations

Note the following within the project:

  • The project has a model made up of SchoolContext.cs in the Models/Data directory as well as ...