0

I'm on Visual Studio 2019 v16.4.3. I tried publishing my ASP.NET Core MVC web app to Azure and followed the steps shown here:

Publish an ASP.NET Core app to Azure with Visual Studio Code

But I'm stuck at this part of the tutorial:

enter image description here

I tried running both these commands:

dotnet tool install dotnet-ef

and

dotnet tool install dotnet-ef --version 3.1.1

but I'm given the same error as the one in the image: "Tool 'dotnet-ef' failed to install."

I already have a local sql db filled with data but it's not sent to the Azure SQL Database that was setup. The database context and tables weren't created on the Azure SQL Database either. How do I get my database with all its data synced and published to the Azure SQL Database? Thanks!

Devwulf
  • 370
  • 4
  • 11

1 Answers1

0

So I've finally found the answer with the help of this answer: https://stackoverflow.com/a/58926602/5874473

First, go to Tools > Options > Environment > Preview Features, then check the option: Use previews of the .NET Core SDK (requires restart)

Afterwards, close Visual Studio and make sure that MSBuildSDKsPath has the correct folder path. To do that, open the Start menu, search "environment variables", then click Edit the system environment variables.

On the new window that popped up, click Environment Variables... on the bottom right. Then in the System variables table (the lower half), look for MSBuildSDKsPath and make sure that it points to a 3.x sdk.

If not, edit it, click Browse Directory, then go to C:\Program Files\dotnet\sdk and open the 3.x folder. For mine, it was 3.1.101. After opening it, select the Sdks folder then click on the three OK buttons to save the changes.

Afterwards, open Visual Studio 2019 again. In the Package Manager Console, type:

dotnet tool install dotnet-ef

and it should work now.

Afterwards, make sure to check the checkbox under Entity Framework Migrations. To do that, right-click on the solution then click Publish. Then near the top, under the Web Deploy name, there are 4 buttons/links (New, Edit, Rename, Delete). Click Edit, then click Settings, then the Entity Framework Migrations, then check that box. Don't forget to check the box under Databases too, if you haven't done so already. Then click Save, then click Publish on the top right!

Devwulf
  • 370
  • 4
  • 11