.NET Core SDK (reflecting any global.json):
Version: 2.1.302
Commit: 9048955601
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.13
OS Platform: Darwin
RID: osx.10.13-x64
Base Path: /usr/local/share/dotnet/sdk/2.1.302/
Host (useful for support):
Version: 2.1.2
Commit: 811c3ce6c0
.NET Core SDKs installed:
2.1.302 [/usr/local/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
dotnet and dotnet-sdk were installed via brew cask install dotnet dotnet-sdk.
There are no other versions installed.
Now I've got a .net core project which is using EF core as well. My .csproj files are only referencing the target framework and the lang version:
<TargetFramework>netcoreapp2.1</TargetFramework>
<LangVersion>7.2</LangVersion>
It compiles, and it works (both on local develop and in the docker environment)
But when I add something to the data model and run dotnet ef migrations list or add the following message occurs:
> dotnet ef migrations list
It was not possible to find any compatible framework version
The specified framework 'Microsoft.NETCore.App', version '2.1.0' was not found.
- Check application dependencies and target a framework version installed at:
/usr/local/share/dotnet/
- Installing .NET Core prerequisites might help resolve this problem:
http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
- The .NET Core framework and SDK can be installed from:
https://aka.ms/dotnet-download
- The following versions are installed:
2.1.2 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
There is _NO_ reference to 2.1.0, like, nowhere :-)
Where is this referenced and why? I don't want to pin down the exact version in the xml :-(
I hope someone can help me with this matter.
Regards
@ajcvickers
@buehler What packages do you have installed?
@ajcvickers what do you mean by packages installed?
I've got dotnet sdk, and installed EFCore.
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.1" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.1.1" />
Can you show your entire csproj and .runtimeconfig.json (this is in the bin folder)
Of course:
csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<LangVersion>7.2</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.1" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.1.1" />
</ItemGroup>
</Project>
bin/Debug/netcoreapp2.1/Time.Data.deps.json:
big bunch of json
@buehler Can you also specify your runtimeconfig.json. You posted your deps.json which is less important.
Uhm.. @davidfowl I don't really have a runtimeconfig.json Where should that file be located at? (I'm on macos)
@buehler So this is a class library, not an application?
@davidfowl Yes. This is a class library.
The structure is as follows:
/
| - BusinessLogicProject
| - DataProject
\ - WebApp
So in the BusinessLogic I reference to the Data (both are class libraries).
And entity framework is located in the dataproject. And in there, I'm trying to dotnet ef migrations list.
cc @bricelam
Does it work when you add...
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.1.1" />
If so, I think this is a new manifestation of the "no design-time lifting" issue. (Possibly not.)
Better question: If you don't add Microsoft.EntityFrameworkCore.Design, but instead add this...
<PropertyGroup>
<GenerateRuntimeConfigurationFiles>True</GenerateRuntimeConfigurationFiles>
</PropertyGroup>
Does it tell you to add the design package?
Mhmm I've heard of the Design package.
_BUT_: when I add the GenerateRuntime thingy and the .csproj file looks like this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<LangVersion>7.2</LangVersion>
<GenerateRuntimeConfigurationFiles>True</GenerateRuntimeConfigurationFiles>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.1" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.1.1" />
</ItemGroup>
</Project>
It works. What exactly is the issue? (So I can understand the issue and understand the consequences)
EF needs the *.runtimeConfig.json file to get framework roll forward behavior. Class libraries don't generate a *.runtimeConfig.json by default. The Design package basically adds this line to your project. If none of that happens, we fall back to running on the exact version the library is compiled against which fails if it's not installed.
Oh :-) well that clarifies the issue. Thanks for the help!
Would you suggest to add the design package or to add the line?
If it works just by adding the line, I'd do that--less work for NuGet.
Most helpful comment
EF needs the *.runtimeConfig.json file to get framework roll forward behavior. Class libraries don't generate a *.runtimeConfig.json by default. The Design package basically adds this line to your project. If none of that happens, we fall back to running on the exact version the library is compiled against which fails if it's not installed.