Reputation: 61
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:
Upvotes: 3
Views: 8687
Reputation: 1
I had a similar error but with View. Only one thing helped me: I deleted all packages that were in Package Source Mapping. (Tools->NuGet Package Manager->Package Manager Setting->Package Source Mapping->Remove All).
Upvotes: 0
Reputation: 1
I had the same issue with .Net 7.0 and I was installing the NuGet packages in the 7.0.0 version. I just updated all of them and became 7.0.4 and 7.0.5. After that, I was able to Scaffold.
Upvotes: 0
Reputation: 31
In my case, I've installed CodeGeneration, CodeGeneration.Design nuget package and I've upgraded.net version to maximum version and upgraded all my packages to max. This happens when scaffloding tryies to install the maximum version of package which is ahead of your project .net version.
Upvotes: 1
Reputation: 1
Yes , the same issue for me worked after Updating all the NuGet packages from (v6.0.6---->v6.0.7)
Solution : Update NuGet package
Upvotes: 0
Reputation: 1
I am using VS2022 and .NET CORE 6. I faced with the same issues and solved it buy updating all installed nuget packages.
Upvotes: 0
Reputation: 11
I'm using .net core 5 and had the same issue. To fix this, i try to downgrade both Microsoft.EntityFrameworkCore.Tools and Microsoft.EntityFrameworkCore.SqlServer from 5.0.15 to 5.0.12
after downgrading, i add this "Microsoft.VisualStudio.Web.CodeGeneration.Design" then try to readd new scaffold item and it works on me
Upvotes: 1
Reputation: 21
I had the same issue. The problem was the versions of various NuGet packages (see screenshot). My problem was with an existing project, so I created a new project and did the scaffolding successfully. After that, I used the same package versions for my existing project.
I updated the following packages in the screenshot to the same version and everything worked.
Upvotes: 2
Reputation: 1285
I had the same issue. I downgranded the Microsoft.EntityFrameworkCore.Tools
and Microsoft.EntityFrameworkCore.SqlServer
to 5.0.4 and problem solved.
Upvotes: 4