I'm getting the following error trying to create a migration using EF Core 3.1.
PM> add-migration InitialDB
Unable to resolve startup project ''.
Using project 'UI\UI.Web' as the startup project.
Build started...
Build succeeded.
System.IO.FileLoadException: Could not load file or assembly 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.AddMigration(String name, String outputDir, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)Could not load file or assembly 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Is there any thing I need to do to get my project to get migrations to support .NET Core 3.0/3.1?
Any help would be greatly appreciated.
I recently ran into the same issue for myself after upgrading my EF Core from 2.2
to 3.1.6
, and after some investigating into the issue, it looks like if you try and bump up your RuntimeFrameworkVersion
in your .csproj
file it may fix the issue. This seemed to fix it for me, remember that there are only certain compatible .NET Core frameworks available based on your configuration. If you incorrectly set it to a version that does not exist, you will see this
It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '3.1.0' was not found.
- The following frameworks were found:
2.0.9 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
2.1.0 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
2.1.7 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
2.1.11 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
2.1.20 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
3.1.6 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
After updating the RuntimeFrameworkVersion
that you have supported on your development environment, your .csproj
may look something like this
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
<GenerateRuntimeConfigurationFiles> true</GenerateRuntimeConfigurationFiles>
<RuntimeFrameworkVersion>3.1.6</RuntimeFrameworkVersion>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
Hope this assists you as it assisted me. But if it does not, you may also edit the .csproj
file to enable all private and entity assets to be included
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
P.S. First time posting an answer on stack overflow, so I apologize in advance if this does not assist you and I hope it helps you.
User contributions licensed under CC BY-SA 3.0