Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to deploy locally, error 'The model for context 'CatalogContext' has pending changes' #149

Open
eblikstad opened this issue Jan 30, 2025 · 4 comments
Assignees

Comments

@eblikstad
Copy link

eblikstad commented Jan 30, 2025

I'm using the eShopOnWeb for simple on-premises architecture operations testing and have deployed the application for every .NET version, but I cannot deploy it on .NET version 9.0. When creating the first database I get an error. I'm have downloaded the source from the main branch. Is there a specific branch I need to use for local deployment on Windows Server 2022 & .NET 9.0.

Database update output:
C:\eShopOnWeb-main\src\Web>dotnet ef database update -c catalogcontext -p ../Infrastructure/Infrastructure.csproj -s Web.csproj
Build started...
Build succeeded.
The Entity Framework tools version '8.0.0' is older than that of the runtime '9.0.1'. Update the tools for the latest features and bug fixes. See https://aka.ms/AAc1fbw for more information.
System.InvalidOperationException: An error was generated for warning 'Microsoft.EntityFrameworkCore.Migrations.PendingModelChangesWarning': The model for context 'CatalogContext' has pending changes. Add a new migration before updating the database. See https://aka.ms/efcore-docs-pending-changes. This exception can be suppressed or logged by passing event ID 'RelationalEventId.PendingModelChangesWarning' to the 'ConfigureWarnings' method in 'DbContext.OnConfiguring' or 'AddDbContext'.
at Microsoft.EntityFrameworkCore.Diagnostics.EventDefinition1.Log[TLoggerCategory](IDiagnosticsLogger1 logger, TParam arg)
at Microsoft.EntityFrameworkCore.Diagnostics.RelationalLoggerExtensions.PendingModelChangesWarning(IDiagnosticsLogger`1 diagnostics, Type contextType)
at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.ValidateMigrations(Boolean useTransaction)
at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String connectionString, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(String targetMigration, String connectionString, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_0.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
An error was generated for warning 'Microsoft.EntityFrameworkCore.Migrations.PendingModelChangesWarning': The model for context 'CatalogContext' has pending changes. Add a new migration before updating the database. See https://aka.ms/efcore-docs-pending-changes. This exception can be suppressed or logged by passing event ID 'RelationalEventId.PendingModelChangesWarning' to the 'ConfigureWarnings' method in 'DbContext.OnConfiguring' or 'AddDbContext'.

@sadukie
Copy link
Contributor

sadukie commented Jan 30, 2025

Looking at the output, it looks like you're using an older version of the Entity Framework tools:

The Entity Framework tools version '8.0.0' is older than that of the runtime '9.0.1'.

You can confirm the version of your tools by running this at a command prompt:

dotnet ef --version

With .NET 9, you'll want to use the newer version. Since you already have the tools installed, you can update it with this command:

dotnet tool update --global dotnet-ef

@sadukie
Copy link
Contributor

sadukie commented Feb 7, 2025

Looking into this further, this issue looks like it's rooted in the codebase in src/Web/.config/dotnet-tools.json

Checking some things here before submitting a PR to fix it.

@sadukie
Copy link
Contributor

sadukie commented Feb 7, 2025

This definitely goes beyond the dotnet-ef tool update.

Once the dotnet-ef tool update happens, the Identity context can be updated.

However, the CatalogContext still has changes. Looking to see what is going on with that.

@sadukie
Copy link
Contributor

sadukie commented Feb 7, 2025

@eblikstad Both of the issues seen in this report have been addressed in #161 . Please let us know if this fixed your deployment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants