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

The model for context 'PostgresContext' has pending changes. #1333

Open
Oleh213 opened this issue Jan 27, 2025 · 0 comments
Open

The model for context 'PostgresContext' has pending changes. #1333

Oleh213 opened this issue Jan 27, 2025 · 0 comments
Assignees

Comments

@Oleh213
Copy link

Oleh213 commented Jan 27, 2025

Hi,

When we moved to .Net 9 and update packages we got this issue:

Unhandled exception. System.AggregateException: One or more errors occurred. (An error was generated for warning 'Microsoft.EntityFrameworkCore.Migrations.PendingModelChangesWarning': The model for context 'PostgresContext' 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'.)
---> System.InvalidOperationException: An error was generated for warning 'Microsoft.EntityFrameworkCore.Migrations.PendingModelChangesWarning': The model for context 'PostgresContext' 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 Npgsql.EntityFrameworkCore.PostgreSQL.Migrations.Internal.NpgsqlMigrator.Migrate(String targetMigration)
at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.Migrate(DatabaseFacade databaseFacade)
at WorkflowCore.Persistence.EntityFramework.Services.EntityFrameworkPersistenceProvider.EnsureStoreExists()
at WorkflowCore.Services.WorkflowHost.StartAsync(CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at WorkflowCore.Services.WorkflowHost.Start()
at Cyclix.Workflow.WorkflowServiceCollectionExtensions.RegisterWorkflows(IApplicationBuilder app, Assembly[] assemblies)

Image

.AddWorkflow(options => options.UsePostgreSQL(connectionString: appSettings.ConnectionStrings.PostgresWorkflowDb, true, true))

`

public static void RegisterWorkflows(this IApplicationBuilder app, params Assembly[] assemblies)
{
    var host = app.ApplicationServices.GetService<IWorkflowHost>();
    
    host.RegisterWorkflow<ShopServiceJobWorkflow, ShopServiceJobWorkflowContext>();
    host.RegisterWorkflow<CustomerServiceRequestWorkflow, CustomerServiceRequestWorkflowContext>();

    host.Start();
}

`

WorkflowCore 3.13.0
WorkflowCore.Persistence.PostgreSQL 3.13.0
Microsoft.EntityFrameworkCore 9.0.1

P.S: Creating a new migration didn't solve this issue

@danielgerlag danielgerlag self-assigned this Jan 28, 2025
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