I'm trying to add initial migrations to my project that is using EF Core + PostGRE SQL Driver
My project structure looks like:
.sln
|--
|
|-- Context(cslib)
|-- Controllers(cslib)
|-- AppRunner(console app), Startup
|--(...)
Where AppRunner has:
PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.1.2"
Context has:
PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.1"
Controllers have:
PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.1"
My Startup:
services
.AddEntityFrameworkNpgsql()
.AddDbContext<Context>
(
o => o
.UseNpgsql(DbConnectionString)
)
.BuildServiceProvider();
And everything works fine - app works correctly, but when I want to perform
dotnet ef migrations add InitialCreate
in AppRunner folder it throws
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileLoadException: Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=2.1.4.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) at Microsoft.EntityFrameworkCore.Design.OperationExecutor..ctor(Object reportHandler, IDictionary args) --- End of inner exception stack trace --- at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions) at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) at Microsoft.EntityFrameworkCore.Tools.ReflectionOperationExecutor..ctor(String assembly, String startupAssembly, String projectDir, String dataDirectory, String rootNamespace, String language) at Microsoft.EntityFrameworkCore.Tools.Commands.ProjectCommandBase.CreateExecutor() at Microsoft.EntityFrameworkCore.Tools.Commands.MigrationsAddCommand.Execute() at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args) at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args) Exception has been thrown by the target of an invocation.
Anybody has an idea what can cause that?
User contributions licensed under CC BY-SA 3.0