dotnet aspnet-codegenerator crash
The command:
dotnet aspnet-codegenerator razorpage -m Movie -dc MovieContext -udl -outDir Pages/Movies --referenceScriptLibraries
Crashes with the following error message:
Building project ...
Finding the generator 'razorpage'...
Running the generator 'razorpage'...
Could not load file or assembly 'System.Collections.Immutable, Version=1.2.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
The located assembly's 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:03.99
Was using .Net Core 2.1.200 and upgraded to 2.1.401 and still the same issue. Linux machine, Ubuntu 16.04
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: b34c4871-adc3-0d13-6f20-6f6ac1f65e91
- Version Independent ID: ea1742b3-808b-d449-3308-6847a9f339f9
- Content: Add a model to an ASP.NET Core Razor Pages app with Visual Studio Code
- Content Source: aspnetcore/tutorials/razor-pages-vsc/model.md
- Product: aspnet-core
- GitHub Login: @Rick-Anderson
- Microsoft Alias: riande
'System.Collections.Immutable, Version=1.2.3.0 can't be correct. What does your project file look like?
Here are the instructions for the updated RP/EF tutorial. Adjust them for your project
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design --version 2.1.0
dotnet aspnet-codegenerator razorpage -m Student -dc ContosoUniversity.Models.SchoolContext -udl -outDir Pages\Students --referenceScriptLibraries
This is my project. It was target framework netcoreapp2.0 and I changed it to 2.1 and Microsoft.AspNetCore.All changed it to 2.1.3 (it was 2.0.8) and now it works. I think what happened is that I started the tutorial in 2.1.200 and so the template had old references.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.3" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.3" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" />
</ItemGroup>
</Project>
@nelfer thanks for the update. This will probably help someone else out.