Distribution of version mismatch of the initial version of .NET Entity Framework

I am trying to go through the Contoso University textbook located here:

https://docs.microsoft.com/en-us/aspnet/core/data/ef-rp/intro

I went through all the steps before completing the line dotnet aspnet-codegenerator. When I get this error:

C:\dev\vs\ContosoUniversity\ContosoUniversity>dotnet aspnet-codegenerator razorpage -m Student -dc SchoolContext -udl -outDir Pages\Students --referenceScriptLibraries
Building project ...
Finding the generator 'razorpage'...
Running the generator 'razorpage'...
Attempting to compile the application in memory.
Attempting to figure out the EntityFramework metadata for the model and DbContext: 'Student'
Could not load file or assembly 'Microsoft.EntityFrameworkCore.Design, Version=2.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The located assembly manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
   at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.<BuildCommandLine>b__6_0()
   at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.Execute(String[] args)
   at Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args)
RunTime 00:00:08.32

I made sure I upgrade my version of EF Core to the latest version: Install-Package Microsoft.EntityFrameworkCore -Version 2.0.2

My NuGet dependencies show Microsoft.EntityFrameworkCore (2.0.2).

Here is my project file:

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.0.2" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.3" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Utils" Version="2.0.3" />
  </ItemGroup>
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.2" />
  </ItemGroup>
</Project>

What do I need to do to get through this error?

+4
source share

Source: https://habr.com/ru/post/1694995/


All Articles