Share via

Error: 'Package restore failed rolling back package change for' while running Scaffold-Dbcontext in Entity Framework Core 7.0.14

Anonymous
2023-12-19T20:12:20.84+00:00

Hello,

I'm working on a project using .NET Core 7 and encountering an issue when running Scaffold-DbContext with Entity Framework 7.0.14. The error message I'm getting is "there was an error running the selected code generator package restore failed rolling back package chanse for." I'm seeking guidance on resolving this issue in the context of .NET Core 7.

Versions I'm using:

  • .NET Core 7
  • Entity Framework 7.0.14
  • Project GitHub link: GitHub Link

If anyone has encountered a similar problem or has suggestions on how to address this, I would greatly appreciate any help. Thank you.

I attempted to generate a DbContext using Scaffold-DbContext in Entity Framework Core 7.0.14 within my .NET Core 7 project. I expected the command to execute successfully and create the necessary DbContext based on my database schema. However, during the process, I encountered an error

There was an error running the selected code generator package restore failed rolling back package change for

Despite multiple attempts, I couldn't resolve this issue. Seeking advice on resolving this error in the context of .NET Core 7 and Entity Framework Core 7.0.14Ekran görüntüsü 2023-12-19 193512

Ekran görüntüsü 2023-12-19 193438

Ekran görüntüsü 2023-12-19 184710

Ekran görüntüsü 2023-12-19 184743

 public class ApplicationDbContext : IdentityDbContext
    {
        public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options)
        {
        }
        public DbSet<Category> Categories { get; set; }
        public DbSet<Product> Products { get; set; }
        public DbSet<ProductPrice> ProductPrices { get; set; }
        public DbSet<OrderDetail> OrderDetails { get; set; }
        public DbSet<OrderHeader> OrderHeaders { get; set; }

    }
Developer technologies | .NET | Entity Framework Core
Developer technologies | ASP.NET | ASP.NET Core

6 answers

Sort by: Most helpful
  1. Ian Hewitt 0 Reputation points
    2024-05-01T12:35:50.3466667+00:00

    I'm using VS2022 (17.9.6) and just had the same issue.

    I updated the NuGet packages.

    I cleaned the solution

    I cleaned the project

    I did a rebuilt on the solution and how it's working again. Hope this might help someone else in future as all other solutions I tried didn't work for me

    Was this answer helpful?

    0 comments No comments

  2. Hoang Anh Vu 5 Reputation points
    2024-03-19T02:31:34.14+00:00

    I have resolved it by using .NET CLI described in the document. https://learn.microsoft.com/en-us/aspnet/core/security/authentication/scaffold-identity?view=aspnetcore-6.0&tabs=netcore-cli#scaffold-identity-into-a-razor-project-without-existing-authorization-1

    For example, I'm using an existing db context

    dotnet aspnet-codegenerator identity --dbContext MyDbContext

    Please be noted that the target framework and version of all packages should be the same (6.x/7.x/8.x)

    Was this answer helpful?

    0 comments No comments

  3. Hoang Nguyen 0 Reputation points
    2024-02-04T12:51:18.8266667+00:00

    Did you address this problem? I also have this problem and don't know how to address

    Was this answer helpful?


  4. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  5. Anonymous
    2023-12-20T08:57:14.0666667+00:00

    There is no version 7.0.14. I updated the others to 7.0.11, but it still didn't work. But when I upgraded my project to .net 8, it worked but I started getting other errors. I need to make the project with .net7Ekran görüntüsü 2023-12-20 115429

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.