I have run the following command to update my EF Core Tools:
dotnet tool update --global dotnet-ef
After running it, I tried to run
dotnet ef --version
But then it threw this error:
It was not possible to find any compatible framework version The
framework 'Microsoft.NETCore.App', version '3.1.2' was not found.
- The following frameworks were found:
2.1.13 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
2.2.7 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
3.0.0 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
3.1.1 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.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.NETCore.App&framework_version=3.1.2&arch=x64&rid=win10-x64
After seeing it I followed the link and downloaded all possible packages but nothing changed.
How do I resolve this problem?
I have found a way to solve this problem. Worth noting, however, it's not the best approach:
dotnet tool uninstall --global dotnet-ef
dotnet tool install --global dotnet-ef --version 3.1.1
What packages did you download?
The dotnet ef you are using is of version 3.1.2 but
your .net core desktop runtime 3.1 version is below the version 3.1.2
All you need to do is to download the .net core runtime 3.1 version 3.1.2
https://dotnet.microsoft.com/download/dotnet-core/3.1/runtime/?utm_source=getdotnetcore&utm_medium=referral
I am trying to use EF Core 3 in the latest (preview) version of Azure functions, but I am getting the following error when I try interacting with the database:
System.Private.CoreLib: Exception while executing function: DemoFunction. Microsoft.Data.SqlClient: Microsoft.Data.SqlClient is not supported on this platform.
I have a web app in the same solution that works just fine with the same setup, and there is nothing special about my "platform". This is the output from dotnet --info:
.NET Core SDK (reflecting any global.json): Version:
3.1.100-preview2-014569 Commit: 4bd5d24d87
Runtime Environment: OS Name: Windows OS Version: 10.0.18362
OS Platform: Windows RID: win10-x64 Base Path: C:\Program
Files\dotnet\sdk\3.1.100-preview2-014569\
Host (useful for support): Version: 3.1.0-preview2.19525.6 Commit:
5672978d91
.NET Core SDKs installed:
2.1.801 [C:\Program Files\dotnet\sdk]
2.1.802 [C:\Program Files\dotnet\sdk]
3.0.100 [C:\Program Files\dotnet\sdk]
3.1.100-preview2-014569 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.12
[C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.13 [C:\Program
Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.12 [C:\Program
Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.13 [C:\Program
Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0 [C:\Program
Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.0-preview2.19528.8 [C:\Program
Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App
2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.13 [C:\Program
Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App
3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.0-preview2.19525.6 [C:\Program
Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.0.0 [C:\Program
Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.0-preview2.19525.6 [C:\Program
Files\dotnet\shared\Microsoft.WindowsDesktop.App]
I have created a minimal reproduction of the issue here, just start up the functions project and send it an HTTP request (same with the web app).
Is it currently possible to use EF Core 3 with v3 Azure Functions? (FYI I have a v2 Functions app running with EF Core 2.1)
This issue has been solved , copy OP's comment , it will be helpful for others have similar issue :
looks like there is a workaround that solves my issue
As a workaround, add the following code to .csproj:
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy $(OutDir)$(ProjectName).deps.json $(OutDir)bin\function.deps.json" />
</Target>
<Target Name="PostPublish" BeforeTargets="Publish">
<Exec Command="copy $(PublishDir)$(ProjectName).deps.json $(PublishDir)bin\function.deps.json" />
</Target>
Another fix is to move from Microsoft.NET.Sdk.Functions" Version="3.0.8" back to 3.0.7
Reference: https://github.com/Azure/Azure-Functions/issues/1370#issuecomment-654698010
I am working through a tutorial on .Net core apps and Visual Studio Code, and cannot add a package to the app.
Using the CLI I did:
dotnet new console
dotnet run
Which worked fine.
Then I run:
dotnet add package System.Net.Http
And got this result:
$ dotnet add package System.Net.Http
Writing C:\Users\xxx\AppData\Local\Temp\tmpF935.tmp
info : Adding PackageReference for package 'System.Net.Http' into project 'C:\Visual Studio Code\learning-module\learning-module.csproj'.
log : Restoring packages for C:\Visual Studio Code\learning-module\learning-module.csproj...
error: Unable to resolve 'System.Net.Http ' for '.NETCoreApp,Version=v2.2'.
error: Package 'System.Net.Http' is incompatible with 'all' frameworks in project 'C:\Visual Studio Code\learning-module\learning-module.csproj'.
I've tried manually adding the package to the project file and running restore; changing the target framework; running from the console rather than Visual Studio Code; and trying different common packages, but nothing seems to resolve.
$ dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 2.2.103
Commit: 8edbc2570a
Runtime Environment:
OS Name: Windows
OS Version: 10.0.14393
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.2.103\
Host (useful for support):
Version: 2.2.1
Commit: 878dd11e62
.NET Core SDKs installed:
2.1.503 [C:\Program Files\dotnet\sdk]
2.2.103 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
Does anyone know what else I could try or how to find out more info on this issue?
System.Net.Http is a standard namespace in .Net Core 2. You shouldn't need to add an external package.
Just put a using statement at the top of your code:
using System.Net.Http;
I'm working to automate my build Devops Pipelines. My Visual Studio (15.9.7) build succeeds, but when I try the build in Devops Pipelines, I get the error:
Error : NETSDK1061: The project was restored using
Microsoft.NETCore.App version 1.0.0,
but with current settings, version 2.1.0 would be used instead.
To resolve this issue, make sure the same settings are used for
restore and for subsequent operations such as build or publish.
Typically this issue can occur if the RuntimeIdentifier property is
set during build or publish but not during restore. For more
information, see
https://aka.ms/dotnet-runtime-patch-selection.
I've tried using a Microsoft build agent (VS2017) as well as using the machine where I have a successful build from Visual Studio. In both cases, I get the same error.
I've looked for references to Microsoft.NETCore.App using text searches across all the files and am not finding any references to 1.0.0.
As another data point, here's my output of dotnet --info:
.NET Core SDK (reflecting any global.json):
Version: 2.2.103
Commit: 8edbc2570a
Runtime Environment:
OS Name: Windows
OS Version: 10.0.17134
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.2.103\
Host (useful for support):
Version: 2.2.1
Commit: 878dd11e62
.NET Core SDKs installed:
2.1.503 [C:\Program Files\dotnet\sdk]
2.1.504 [C:\Program Files\dotnet\sdk]
2.2.103 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
The fix for my issue turned out to be in another question on StackOverflow that I missed in my original searches. The fix was to:
Set the RuntimeIdentifiers property to a semicolon-separated list of all the RIDs to be published.
Set the TargetLatestRuntimePatch property to true.
When I use the dotnet ef tools in the VS 2017 Package Manager Console I get a warning message about needing to update EF Core tools:
PM> dotnet ef migrations list -s ../RideMonitorSite
The EF Core tools version '2.1.1-rtm-30846' is older than that of the runtime '2.1.2-rtm-30932'. Update the tools for the latest features and bug fixes.
20180831043252_Initial
But my csproj file has this entry:
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.1.2" />
</ItemGroup>
I've confirmed that the version installed is, in fact, out of date:
PM> dotnet ef --version
Entity Framework Core .NET Command-line Tools
2.1.1-rtm-30846
So what do I do to update the tools? BTW, I've seen in other answers that an out of date global.json file can cause this problem. But I don't have a global.json file anywhere in the solution.
Use command line, Cmd or PowerShell for specific version:
dotnet tool update --global dotnet-ef --version 3.1.0
or for latest version use (works also for reinstallation):
dotnet tool update --global dotnet-ef
I bounced this issue over to the development team over on github. Turns out this is a known issue in the current tooling or nuget packages that get loaded when you create an EF Core-powered AspNet Core site. It's targeted to be fixed in a future release.
For now, the workaround is simply to ignore the warning.
Another workaround is also offered, involving tweaking the csproj file to define the version of the AspNet Core metapackage explicitly -- it's up to 2.1.3 as I'm writing this -- but I couldn't get that approach to work; I still kept getting the warning message.
for .NET 6, it would be
dotnet tool update --global dotnet-ef --version 6.0.0
The solution that worked for me is running the following commands in Package Manager Console:
PM> Install-Package Microsoft.EntityFrameworkCore -Version 2.1.11
PM> Install-Package Microsoft.EntityFrameworkCore.Tools -Version 2.1.11
Make sure the version matches the one in the error message in my case I got the following error:
The EF Core tools version '2.1.1-rtm-30846' is older than that of the runtime '2.1.11-servicing-32099'. Update the tools for the latest features and bug fixes.
Check the versions available from the following site:
https://www.nuget.org/packages/Microsoft.EntityFrameworkCore/
Try this one:
Install-Package Microsoft.EntityFrameworkCore.Tools
If problem still occurs, then execute this also:
Update-Package Microsoft.EntityFrameworkCore.Tools
My solution was to install the tool dotnet-ef from microsoft https://www.nuget.org/packages/dotnet-ef. It uses the same commands but no warnings. The change is to use dotnet-ef instead of dotnet ef.
And if you already have dotnet-ef installed then use
dotnet tool update --global dotnet-ef --version n.n.n (n.n.n your version to update to)
To Solve This Issue You May Follow One Of The Following Techniques:
Technique 1: Using Package Manager Console(Especially for Microsoft Visual Studio user) PM> Install-Package Microsoft.EntityFrameworkCore.Tools -Version 2.1.2
Technique 2: Using .NET CLI > dotnet add package Microsoft.EntityFrameworkCore.Tools --version 2.1.2
Technique 3: Using Package Reference
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Technique 4: Using Packet CLI > paket add Microsoft.EntityFrameworkCore.Tools --version 2.1.2
Remember: For this version to use you need NuGet 3.6 or higher.
Reference Link: https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.Tools/2.1.2
Install a new .NET Core SDK v2.1.401 version and check >dotnet ef --version again. I had the same issue and in my case, that worked. Also, you don't need to add Microsoft.EntityFrameworkCore.Tools.DotNet.
Ignore the issue
Do not update your < PackageReference Include = " Microsoft . EntityFrameworkCore . Tools " Version ="" / >
In my case, I moved forward with 'Update-Database -Context MyElementContext' and now it is all working fine.
I found this in the book 'Programming ASP.NET Core' by Dino Esposito.
'Note This version of the CLI tooling is not the same as the version of the .NET Core runtime the application will use. The runtime version is specified in the project file, and you can comfortably edit it from within the user interface of the IDE of your choice. If you want, instead, to edit the project file manually, then it is as easy as editing the .csproj XML fi le and changing the value of the TargetFramework element. The value refers to the moniker that identifies the version (such as netcoreapp2.0).'
Like Martin
Use command line, Cmd or PowerShell for specific version:
dotnet tool update --global dotnet-ef --version 3.1.0
or for latest version use (works also for reinstallation):
dotnet tool update --global dotnet-ef
But, I've got probleme in my pc :
"When running the command whitout specifying any version i got the following error: Tool 'dotnet-ef' failed to update due to the following: The tool package could not be restored" Liko Pippo46
So, I use these steps :
dotnet tool uninstall --global dotnet-ef
But got the same problem, so I'm going to the directory of the extension :
C:\Users\Evan.dotnet\tools.store\dotnet-ef
And I found the old version (2.x)
And my second problem was the file fileproject.assets.json was not found
So I copy the fileproject.assets.json in the 2.x version to the parent repository
And all was done perfectly :
dotnet tool uninstall --global dotnet-ef
removes the 2.x version
dotnet tool install --global dotnet-ef
install the 3.1 one
I couldn't find how to update the package specifically, but in the Package Manager Console I ran 'update-package'. It ran through and updated all packages referenced in a project, including the EF Core Tools. That may not be ideal for you as that could update packages you didn't want.
Following the steps in this document helped me solve the problem - https://docs.oracle.com/cd/E17952_01/connector-net-en/connector-net-entityframework-core-scaffold-example.html
Scaffolding a Database Using Package Manager Console in Visual Studio
Open Visual Studio and create a new Console App (.NET Core) for C#.
Add the MySQL NuGet package for EF Core using the Package Manager Console. For example, use the following command to add the MySql.Data.EntityFrameworkCore v8.0.13 package:
Install-Package MySql.Data.EntityFrameworkCore -Version 8.0.13
Important
The version (for example, -Version 8.0.13) must match the actual Connector/NET version you are using. For current version information.
Install the following NuGet packages by selecting either Package
Manager Console or Manage NuGet Packages for Solution from the Tools
and then NuGet Package Manager menu:
Microsoft.EntityFrameworkCore.Design
EF Core 1.1 only: Also add the MySql.Data.EntityFrameworkCore.Design package.
Microsoft.EntityFrameworkCore.Tools version 1.1.6 (for EF Core 1.1) and Microsoft.EntityFrameworkCore.Tools version 2.0.3 (for EF Core 2.0)
Note
The .NET tools are included in the .NET Core 2.1 SDK and not required or supported for EF Core 2.1. If this is an upgrade, remove the reference to that package from the .csproj file (version 2.0.3 in this example) :
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.3" />
Open Package Manager Console and enter the following command at the prompt to create the entities and DbContext for the sakila database (adjust the connection-string values to match your settings for the user= and password= options):
Scaffold-DbContext "server=localhost;port=3306;user=root;password=mypass;database=sakila"
MySql.Data.EntityFrameworkCore -OutputDir sakila -f
Visual Studio creates a new sakila folder inside the project, which contains all the tables mapped to entities and the sakilaContext.cs file.
Even though the Oracle instructions said that Microsoft.EntityFrameworkCore.Tools was not needed for EF Core 2.1 I installed the version 2.2.0 that is compatible with EF 2.2
Update EF Core tools using dotnet CLI or Package Manager Console or visiting
this site https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.Tools/2.1.2
Or you may ignore this. It's not a big issue...
In your application, Dot.net core library version is 2.1.2 and you are working on 2.1.1 of Entity framework core(2.1.1).
So, Update your library version which should be equal to dot.net core version (2.1.2).
I got this error multiple times my packages was up to date in NuGet package manager
So I modified (.csproj) with note pad to the desired version and it solved my problem.