Search code examples
visual-studio-codeentity-framework-core

EntityFrameworkCore how to run "Update-Database" & "Add-Migration" from Visual Studio Code (VSCode)


I am trying EntityFrameworkCore in Visual Studio Code and I want to run "Update-Database" and "Add-Migration' commands, but there is no Package Manager Console in VSCode. what to do?


Solution

  • Yes, you can always do this with vscode.

    Install the dotnet ef tool by running the preceding command.

    dotnet tool install --global dotnet-ef
    

    You should get a message in the command prompt as below.

    You can invoke the tool using the following command: dotnet-ef Tool 'dotnet-ef' (version '5.0.3') was successfully installed.

    Now you should be able to run any ef commands. For example,

    dotnet ef database update
    

    That will give you a response as below.

    Build started...

    Build succeeded.

    Done.

    Just sharing this, as some people might have not installed the ef tools.