Brand new .NET Core class library project with a simple DbContext.
When I run dotnet ef migrations add I get the following exception.
I am pretty sure it was working a few days ago with the 2.preview version.
$ dotnet ef migrations add initial
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileLoadException: Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=4.0.2.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder.TryAddCoreServices()
at Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.ApplyServices(IDbContextOptions options, ServiceCollection services)
at Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.<>c__DisplayClass4_0.<GetOrAdd>b__2(Int64 k)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at Microsoft.EntityFrameworkCore.DbContext..ctor(DbContextOptions options)
at AddMigrationRepro.Db..ctor()
--- End of inner exception stack trace ---
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.<>c__DisplayClass12_3.<FindContextTypes>b__13()
at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(Func`1 factory)
at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(String contextType)
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.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Exception has been thrown by the target of an invocation.
My .csproj file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
</ItemGroup>
</Project>
EF Core version: 2.0.0
dotnet version: 2.0.0-preview2-006497
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Windows 8.1
IDE: Visual Studio 2017 15.3.0 preview 7.1
You need to install dotnet CLI version 2.0 (RTM), The preview2 CLI is not compatible with EF Core 2.0 RTM packages
@smitpatel Where can we download the dotnet CLI v2.0 RTM from?
Pls be patient!
@ErikEJ I'm confused. What is there to be patient about? Are you saying that the dotnet CLI v2.0 RTM hasn't been released yet?
@TAGC Not yet, but maybe soon!
@ErikEJ To make sure I'm understanding this correctly - Microsoft released v2.0.0 of all their Microsoft.* NuGet packages on Friday, but anyone who upgrades to them will find their application fails to start unless they upgrade to a dotnet CLI version that doesn't exist yet.
I encountered the exact same issue as @nikolay-spasov and I don't even use Entity Framework. All I'm trying to do is launch my ASP.NET Core application in VS 2017.
That is correct, all I am saying is pls be patient!
It's downloadable if you know where to look. It won't be made convenient till the release announcement. That said, I would agree that it would be more reasonable for RTM releases of libraries that depend on another unreleased dependency should be held back until said dependency is released. Seems more logical than this.
@nikolay-spasov - You can download 2.0 CLI from here https://www.microsoft.com/net/download/core
Most helpful comment
@nikolay-spasov - You can download 2.0 CLI from here https://www.microsoft.com/net/download/core