The `EntityFrameworkStore.DeleteManyAsync` throws error with database other than SQLite since Elsa 2.9
See original GitHub issueHi there, after upgrade to Elsa 2.9.0, some error happens.
- Unable Bulk delete workflow instances.
- Unable publish workflow definitions.
- The CleanupHostedService Failed to perform cleanup.
It may caused by #3286
System.InvalidOperationException: The entity type 'string' was not found. Ensure that the entity type has been added to the model.
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.GetOrCreateEntry(Object entity)
at Microsoft.EntityFrameworkCore.DbContext.EntryWithoutDetectChanges[TEntity](TEntity entity)
at Microsoft.EntityFrameworkCore.DbContext.Remove[TEntity](TEntity entity)
at Elsa.Persistence.EntityFramework.Core.Extensions.QueryableBulkExtensions.BatchDeleteWithWorkAroundAsync[T](IQueryable`1 queryable, DbContext elsaContext, CancellationToken cancellationToken)
at Elsa.Persistence.EntityFramework.Core.Stores.EntityFrameworkWorkflowInstanceStore.<>c__DisplayClass5_0.<<DeleteManyByIdsAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Elsa.Persistence.EntityFramework.Core.Stores.EntityFrameworkStore`2.DoWork(Func`2 work, CancellationToken cancellationToken)
at Elsa.Persistence.EntityFramework.Core.Stores.EntityFrameworkStore`2.DoWork(Func`2 work, CancellationToken cancellationToken)
at Elsa.Persistence.EntityFramework.Core.Stores.EntityFrameworkWorkflowInstanceStore.DeleteManyByIdsAsync(IEnumerable`1 ids, CancellationToken cancellationToken)
at Elsa.Persistence.EntityFramework.Core.Stores.EntityFrameworkWorkflowInstanceStore.DeleteManyAsync(ISpecification`1 specification, CancellationToken cancellationToken)
at Elsa.Persistence.Decorators.EventPublishingWorkflowInstanceStore.DeleteManyAsync(ISpecification`1 specification, CancellationToken cancellationToken)
at Elsa.Retention.Jobs.CleanupJob.DeleteManyAsync(ICollection`1 workflowInstanceIds, CancellationToken cancellationToken)
at Elsa.Retention.Jobs.CleanupJob.ExecuteAsync(CancellationToken cancellationToken)
at Elsa.Retention.HostedServices.CleanupHostedService.ExecuteAsync(CancellationToken stoppingToken)
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:18 (17 by maintainers)
Top Results From Across the Web
UseMySql() with autoRunMigrations = true would cause ...
This project runs without issue when the database "workflow" does not exist. And the db appears after the app starts.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hello , I think this should be fix with #3345. Indeed , I’ve seen during my test the issue when we don’t use the default database name. And because the notion of schéma is not the same for MySQL , we can remove the schéma name from dbcontext when we use MySQL to avoid this issue.
@sfmskywalker With the latest preview from myget, we getting the following error. Our database is not named Elsa, is the
Elsa.
a accidental missed hardcoded database name in the query?Microsoft.EntityFrameworkCore.Database.Command[20102] Failed executing DbCommand (0ms) [Parameters=[@p0='?' (Size = 4000)], CommandType='Text', CommandTimeout='30'] DELETE FROM Elsa.Triggers WHERE ``WorkflowDefinitionId`` = @p0
Unhandled exception. MySqlConnector.MySqlException (0x80004005): DELETE command denied to user 'elsa_workflow'@'rt1-worker3-221cd339-4qchr.k8s.local.net' for table 'Triggers'