.NET Core 3.1 - dotnet ef add migration error - asp.net-core

When I try to create a migration in my ASP.NET Core 3.1 MVC project, I get this error - I need help
Build started...
Build succeeded.
You must install or update .NET to run this application.
App: /Users/remzi/.dotnet/tools/.store/dotnet-ef/6.0.7/dotnet-ef/6.0.7/tools/net6.0/any/tools/netcoreapp2.0/any/ef.dll
Architecture: arm64
Framework: 'Microsoft.AspNetCore.App', version '3.1.0' (arm64)
.NET location: /usr/local/share/dotnet/
The following frameworks were found:
6.0.7 at [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Learn about framework resolution:
https://aka.ms/dotnet/app-launch-failed
To install missing framework, download:
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.AspNetCore.App&framework_version=3.1.0&arch=arm64&rid=osx.12-arm64

Took me a lifetime to find the solution to this. 3.1 won't work because there is no arm64 version despite what it expects. To get around this you can force it to use this latest by typing the following into the terminal
export DOTNET_ROLL_FORWARD=LatestMajor

Related

How to fix dotnet ef tool, .NET Location not found

I created a .net core 7 project using the entity framework core. Well, at that time I installed .net core 6 so my global ef tool was still version 6, then I updated to version 7. Here I had a problem, it said that I had not installed the framework. I decide to uninstall dotnet. Then I reinstalled sdk 7 and global ef tools. And new error appear. I try reinstall many times. But still like this, now I can't use the ef tool.
This is dotnet --info
.NET SDK:
Version: 7.0.101
Commit: bb24aafa11
Runtime Environment:
OS Name: ubuntu
OS Version: 22.04
OS Platform: Linux
RID: ubuntu.22.04-x64
Base Path: /usr/share/dotnet/sdk/7.0.101/
Host:
Version: 7.0.1
Architecture: x64
Commit: 97203d38ba
.NET SDKs installed:
7.0.101 [/usr/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 7.0.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 7.0.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Other architectures found:
None
Environment variables:
DOTNET_ROOT [/usr/lib/dotnet]
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
And this is the error,
You must install .NET to run this application.
App: /home/apriza/.dotnet/tools/dotnet-ef
Architecture: x64
App host version: 7.0.1
.NET location: Not found
Learn about runtime installation:
https://aka.ms/dotnet/app-launch-failed
Download the .NET runtime:
https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=ubuntu.22.04-x64&apphost_version=7.0.1
I found my answer, I change the Root dotnet env which in /usr/share/dotnet for dotnet 7.
Run export DOTNET_ROOT=/usr/share/dotnet

After moving .NET Core 2.2 web application to new computer with Windows 10, it fails

After moving the application I get this error. I have downloaded and installed SDK 3.1.302 and runtime 3.1.6 but I get this error:
HTTP Error 500.31 - ANCM Failed to Find Native Dependencies
Common solutions to this issue:
The specified version of Microsoft.NetCore.App or Microsoft.AspNetCore.App was not found.
Specific error detected by ANCM:
It was not possible to find any compatible framework version The framework 'Microsoft.AspNetCore.App', version '2.2.0' was not found. - The following frameworks were found: 2.1.20 at [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] 3.1.6 at [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] You can resolve the problem by installing the specified framework and/or SDK. The specified framework can be found at: - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.AspNetCore.App&framework_version=2.2.0&arch=x64&rid=win10-x64
On the SDK .net core download page it says 2.2 is no longer supported and so I downloaded. 3.1.302 as recommended.
However, I think I need to find somewhere in my VS 2019 for that solution and change it to 3.1.6 runtime from 2.2 but I have no idea where that would be.
I looked on the web for a solution but could not find one. I found a mention of removing this
environment variable but that didn't work.
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
Where is my app referencing .net core 2.2? It worked so well on Windows 7 Visual Studio 2017 that I moved it from.
Under project csproj file configuration you have something like <RuntimeFrameworkVersion>2.2</RuntimeFrameworkVersion> or <TargetFramework>netcoreapp2.2</TargetFramework> or <PackageReference Include="Microsoft.AspNetCore.All" Version="2.2" />?
And 2.2 is no longer supported you need back to 2.1 or 3.x. I suggest you to upgrade project to latest version if is it possible.
or you can still download the SDK 2.2 from archive.
https://dotnet.microsoft.com/download/dotnet-core
Installing .Net Core 3.1 does not install the older runtimes by default. You will need to install 2.2, or when you publish your program, publish it as "Self-contained" which should include everything needed to run it.
While 2.2 has been EOLed, you can still run your .net core 2.2 program. You can download the last 2.2 runtime here: https://dotnet.microsoft.com/download/dotnet-core/2.2
You will likely want the Windows Hosting Bundle.
Install that, and once it's complete, you can check your runtime version from powershell with dotnet --list-runtimes
You should see a list of installed runtimes come up. You will want to see something like: Microsoft.NETCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
With that you should be able to run the application.
That being said, I would also recommend updating to 3.1 as soon as possible.

dotnet command not working on centos server, runtime installed

I installed aspnet core runtime (aspnetcore-runtime-3.1.3) on a centOS 7 server.
following this guide from microsoft documentation: https://learn.microsoft.com/en-us/dotnet/core/install/runtime?pivots=os-linux#download-and-manually-install
my server doesn't have internet connection.
After installation, when I run any command, e.g.
dotnet --info
it says it can't find any installed dotnet sdk:
$ dotnet --info
It was not possible to find any installed .NET Core SDKs
Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
https://aka.ms/dotnet-download
Host (useful for support):
Version: 3.1.3
Commit: 4a9f85e9f8
.NET Core SDKs installed:
No SDKs were found.
.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.1.3 [/home/myuser/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.3 [/home/myuser/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
Previously, I downloaded the rpm package and installed it with rpm -ivh command, same result
What can I do to fix this?
Note that I don't have internet access in the server
EDIT: The problem: I don't need SDK to run this command or any command I am using.
Anyways I've tried installing SDK, it says it can't find any compatible frameworks
What is the problem? you just installed runtime, and the error says there is no sdk.
You installed the .net runtime but didn't install the any sdk. for you to be able use asp.net core you need to install both. you can visit asp.net core documentation for the difference between them. but you can just visit https://dotnet.microsoft.com/download to download the appropriate sdk you need.
nb: I assume you are doing this from a gui. i'm sure there are commands for installing the asp.net core runtime and SDK from command prompt. but what is important is that YOU ARE MISSING THE SDK!!

.NET Blazor Build error

I have tried to run the out of the box Blazor application to try out C# WebAssembly. I am running into issues when trying to run it different ways. I have also tried to hack the runtimeconfig.json according to this https://github.com/dotnet/cli/issues/7543
Running IIS Express
Running BlazorApplication1
The program '[42032] dotnet.exe' has exited with code -2147450749 (0x80008083).
Running in command line
It was not possible to find any compatible framework version
The specified framework 'Microsoft.NETCore.App', version '2.0.0-preview3-25512-01' was not found.
- Check application dependencies and target a framework version installed at:
\
- Alternatively, install the framework version '2.0.0-preview3-25512-01'.
You need to have the 2.1 preview of the .net core framework installed for Blazor to work: download here

Not able to create a NET Core 1.1 project when using the command DotNet New

I tried to create a new ASP.NET Core 1.1 project using:
dotnet new
However I got the following error:
The specified framework 'Microsoft.NETCore.App', version '1.0.1' was not found.
Check application dependencies and target a framework version installed at:
The following versions are installed: 1.1.0
Alternatively, install the framework version '1.0.1'.
But I do want to create a 1.1 project. I have the following installed:
What am I missing?