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!