Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not load type

First of all i thank you on your time and i hope that you can understand me even with English as broken as this one:

Could not load type 'Microsoft.EntityFrameworkCore.Infrastructure.IDbContextOptionsExtensionWithDebugInfo' from assembly 'Microsoft.EntityFrameworkCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

Tried to reinstall all packages, to manually put references, restarted PC,restarted VS2019 and even started new project but still error is there again.

I've been here but it didn't help.

services.AddDbContext<ApplicationDbContext>(options =>
                options.UseSqlServer(


Configuration.GetConnectionString("DefaultConnection")));

--.csproj

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <UserSecretsId>aspnet-ZavrsniRad01-F04B6A7E-6450-4254-8092-F42843F4615A</UserSecretsId>
  </PropertyGroup>


  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.0.0-preview6.19307.2" />
    <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.0.0-preview6.19307.2" />
    <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.0.0-preview6.19307.2" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0-preview.18572.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0-preview6.19304.10" />
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.0.0-preview6.19304.6" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.0.0-preview6-19319-03" />
  </ItemGroup>

</Project>
like image 437
Insane Shadow Avatar asked Jul 12 '19 02:07

Insane Shadow


2 Answers

Apparently i had to install EntityFrameworkCore.SqlServer preview6 to solve this error

Install-Package Microsoft.EntityFrameworkCore.SqlServer -Version 3.0.0-preview6.19304.10
like image 96
Insane Shadow Avatar answered Oct 18 '22 19:10

Insane Shadow


I had the same problem with my test project and I saw that the Microsoft.EntityFrameworkCore.SqlServer was missing from my test packages, so I installed the latest version of it and my issue was resolved.

Note: If you are having the same issue with a test do make sure that the Microsoft.EntityFrameworkCore.InMemory version matches the Microsoft.EntityFrameworkCore.SqlServer just for consistency.

enter image description here

like image 42
NSDumb Avatar answered Oct 18 '22 19:10

NSDumb