Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 469
Mkhairy Avatar asked Nov 05 '16 06:11

Mkhairy


People also ask

How do I update my Entity Framework database?

After creating a migration file using the add-migration command, you have to update the database. Execute the Update-Database command to create or modify a database schema. Use the –verbose option to view the SQL statements being applied to the target database.

How do I update my Entity Framework database first?

Right-click anywhere on the design surface, and select Update Model from Database. In the Update Wizard, select the Refresh tab and then select Tables > dbo > Student. Click Finish.


1 Answers

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.

like image 101
Sibeesh Venu Avatar answered Sep 18 '22 13:09

Sibeesh Venu