Could not load file or assembly 'Microsoft.EntityFrameworkCore.SqlServer, Version=1.1.0.0' after upgrading to 1.1.0

38,427

Complete project references clean-up solved my problem.

  1. Delete all bin/obj folders
  2. Delete all project.lock.json files
  3. Delete local Nuget repository cache (computer one)
  4. Remove all references from project.json file and add only required ones (with the help of R#)
  5. nuget udpate, dotnet restore = project is running

When I'm thinking about it again, maybe only point 4 was important?

Share:
38,427
Skorunka František
Author by

Skorunka František

.NET Senior Developer / Team Leader

Updated on July 09, 2022

Comments

  • Skorunka František
    Skorunka František almost 2 years

    I have a Asp.Net Core project targeting .NET 462 and it was working with Asp.Net Core version 1.0.1. After upgrading to "1.1.0" I got this error:

    FileLoadException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.SqlServer, Version=1.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

    project.json

    "dependencies": {
        "AspNet.Mvc.TypedRouting": "1.2.0",
        "AutoMapper": "5.1.1",
        "AutoMapper.Extensions.Microsoft.DependencyInjection": "1.1.2",
        "BundlerMinifier.Core": "2.2.306",
        "JetBrains.Annotations": "10.2.1",
        "libphonenumber-csharp": "7.7.4",
        "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0",
        "Microsoft.AspNetCore.Authentication.Facebook": "1.1.0",
        "Microsoft.AspNetCore.Authentication.Google": "1.1.0",
        "Microsoft.AspNetCore.Authentication.MicrosoftAccount": "1.1.0",
        "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.1.0",
        "Microsoft.AspNetCore.Authentication.Twitter": "1.1.0",
        "Microsoft.AspNetCore.Diagnostics": "1.1.0",
        "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.1.0",
        "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.1.0",
        "Microsoft.AspNetCore.Mvc": "1.1.0",
        "Microsoft.AspNetCore.Razor.Tools": "1.1.0-preview4-final",
        "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
        "Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
        "Microsoft.AspNetCore.Server.Kestrel.Https": "1.1.0",
        "Microsoft.AspNetCore.Session": "1.1.0",
        "Microsoft.AspNetCore.StaticFiles": "1.1.0",
        "Microsoft.EntityFrameworkCore": "1.1.0",
        "Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
        "Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final",
        "Microsoft.Extensions.Configuration": "1.1.0",
        "Microsoft.Extensions.Configuration.Abstractions": "1.1.0",
        "Microsoft.Extensions.Configuration.CommandLine": "1.1.0",
        "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
        "Microsoft.Extensions.Configuration.Json": "1.1.0",
        "Microsoft.Extensions.Configuration.UserSecrets": "1.1.0",
        "Microsoft.Extensions.Logging": "1.1.0",
        "Microsoft.Extensions.Logging.Console": "1.1.0",
        "Microsoft.Extensions.Logging.Debug": "1.1.0",
        "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
        "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.1.0",
        "Microsoft.VisualStudio.Web.CodeGenerators.Mvc": "1.1.0-preview4-final",
        "MotleyFlash": "0.3.0",
        "MotleyFlash.AspNetCore.MessageProviders": "0.2.0",
        "MotleyFlash.AspNetCore.ViewHelpers": "0.2.0",
        "SendGrid.NetCore": "1.0.0-rtm-00002",
        "System.Interactive.Async": "3.1.0",
        "Twilio": "4.7.2"
    },
    "frameworks": {
        "net462": {
            "dependencies": {
                "TaxiGun.Server.IdentityServer.Data": {
                    "target": "project"
                },
                "TaxiGun.Server.Services": {
                    "target": "project"
                }
            }
        }
    },
    

    When I take a look at on build output folder, I can see all the libraries in a proper version except "Microsoft.EntityFrameworkCore.SqlServer": Microsoft.EntityFrameworkCore.SqlServer

    I think it is causing the problem. But I just can not figure out why the version is wrong? Is it because the nuget package has a wrong version inside?

  • Ahmad
    Ahmad about 7 years
    1st point: deleting bin & obj folder then compile again worked for me
  • Bennybear
    Bennybear about 5 years
    Regarding #4, in VS 2017, you can go into your project's .csproj file (project.json was for VS 2015).
  • Jeremy Thompson
    Jeremy Thompson about 5 years
    After multiple tries I eventually did all the steps, in all orders. I eventually had luck specifically adding Microsoft.EntityFrameworkCore.SqlServer and Microsoft.AspNetCore. XYZ specific libraries the project was complaining about missing. Definitely a versioning or API dependency tree issue.
  • taher
    taher about 2 years
    Deleting "bin" and "obj" folders and building the project solved my problem. thank u