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

UMUT CAN 5 Reputation points
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; }

    }
Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
751 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,614 questions
{count} vote

5 answers

Sort by: Most helpful
  1. UMUT CAN 5 Reputation points
    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

    0 comments No comments

  2. 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

  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


  4. 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)

    0 comments No comments

  5. 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

    0 comments No comments

Your answer

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