2
votes

I have created new ASP .Net Core app named 'BankAccount' and when i used to create controller of type 'API controller with actions , using Entity Framework', it gives me the following error => There was an error running the selected code generator: 'Package restore failed'.Rolling back package changes for 'BankAccount'

Here is the version of all my dependencies

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

 <PropertyGroup>
   <TargetFramework>netcoreapp2.1</TargetFramework>
 </PropertyGroup>

 <ItemGroup>
   <Folder Include="wwwroot\" />
 </ItemGroup>

   <ItemGroup>
     <PackageReference Include="Microsoft.AspNetCore.App" />
     <PackageReference Include="Microsoft.AspNetCore.Razor.Language" Version="2.1.0" />
     <PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.0" />
     <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.1.0" />
     <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration" Version="2.1.0" />
     <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.0" />
  </ItemGroup>

 </Project>

This is Visual Studio 2019 Preview Version and here is screenshot of the error:

enter image description here

1
the problem is with the Microsoft.VisualStudio.Web.CodeGeneration and Microsoft.VisualStudio.Web.CodeGeneration. try to change their version.Muhammad Aftab
how the name of both of them is the same ?!Ramy Ayman
second one is Microsoft.VisualStudio.Web.DesignMuhammad Aftab
it gives me two errors about version conflict with aspNetCore 2.1.0Ramy Ayman
I had the issue in scaffolding identity in blazor project. My issue resolved by updating my nuget packages.Tauqir Rao

1 Answers

1
votes

I had the same issue. I downgranded the Microsoft.EntityFrameworkCore.Tools and Microsoft.EntityFrameworkCore.SqlServer to 5.0.4 and problem solved.