Efcore: Could not load file or assembly 'Microsoft.Extensions.Logging... on scaffolding EF dbcontext

Created on 26 Oct 2016  路  4Comments  路  Source: dotnet/efcore

When I run
dotnet ef dbcontext scaffold "User ID=ver_user;Password='';Host=localhost;Port=5432;Database=ver_development;Poolin
g=true;" Npgsql.EntityFrameworkCore.PostgreSQL

I get this message error

System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Extensions.Logging, Version=1.1.0.0, Culture=neutral,
 PublicKeyToken=adb9793829ddae60'. The located assembly's manifest definition does not match the assembly reference. (Excepti
on from HRESULT: 0x80131040)                                                                                                 
File name: 'Microsoft.Extensions.Logging, Version=1.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'                 
   at Microsoft.EntityFrameworkCore.Design.Internal.DesignTimeServicesBuilder.ConfigureServices(IServiceCollection services) 
   at Microsoft.EntityFrameworkCore.Design.Internal.DesignTimeServicesBuilder.Build(String provider)                         
   at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations.ScaffoldContextAsync(String provider, String connectio
nString, String outputDir, String dbContextClassName, IEnumerable`1 schemas, IEnumerable`1 tables, Boolean useDataAnnotations
, Boolean overwriteFiles, CancellationToken cancellationToken)                                                               
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.<ScaffoldContextImpl>d__22.MoveNext()                           
   at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source, Int32& length)                           
   at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source)                                          
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass4_0`1.<Execute>b__0()            
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)                            
Could not load file or assembly 'Microsoft.Extensions.Logging, Version=1.1.0.0, Culture=neutral, PublicKeyToken=adb9793829dda
e60'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) 

this are my dependencies and my tools I have removed bin folder and object and it is the same result, macOS Sierra and Visual Studio Code

  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.1",
      "type": "platform"
    },    
    "Npgsql.EntityFrameworkCore.PostgreSQL": "1.0.2",    
    "Microsoft.EntityFrameworkCore.Design": {
      "version": "1.1.0-preview1-final",
      "type": "build" 
    },


    "Microsoft.AspNetCore.Authentication.Cookies":"1.1.0-preview1-final",
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore":"1.1.0-preview1-final",
    "Microsoft.AspNetCore.Mvc": "1.0.1",
    "Microsoft.AspNetCore.Routing": "1.0.1",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Configuration.CommandLine": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0"
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview3-final",
    "Microsoft.EntityFrameworkCore.Tools.Dotnet": "1.0.0-preview3-final"
  }

Most helpful comment

Hey,

This is because you have a mix of 1.0 and 1.1 packages. You would need to upgrade the AspNetCore and Extensions packages to 1.1 as well.

~Rowan

All 4 comments

Hey,

This is because you have a mix of 1.0 and 1.1 packages. You would need to upgrade the AspNetCore and Extensions packages to 1.1 as well.

~Rowan

I had to upgrade Microsoft.Extensions.Logging to 1.1.0-preview1-final and Removed project.lock.json to make it work, thanks!

works for me

Worked for me

Was this page helpful?
0 / 5 - 0 ratings