Skip to content

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

Open
@Oleh213

Description

@Oleh213

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions