{"record":{"id":"0cc1dba5d1b3a284","repo":"dotnet/efcore","slug":"a-synchronous-store-management-operation-was-perfo-0cc1db","errorCode":null,"errorMessage":"A synchronous store management operation was performed and no synchronous seed delegate has been provided, however an asynchronous seed delegate was. Set 'UseSeeding' option with a delegate equivalent to the one supplied in 'UseAsyncSeeding'.","messagePattern":"A synchronous store management operation was performed and no synchronous seed delegate has been provided, however an asynchronous seed delegate was\\. Set 'UseSeeding' option with a delegate equivalent to the one supplied in 'UseAsyncSeeding'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Migrations/Internal/Migrator.cs","lineNumber":203,"sourceCode":"                    getCommands(), _connection, state, commitTransaction: useTransaction, MigrationTransactionIsolationLevel);\n            }\n\n            var coreOptionsExtension =\n                _contextOptions.FindExtension<CoreOptionsExtension>()\n                ?? new CoreOptionsExtension();\n\n            var seed = coreOptionsExtension.Seeder;\n            if (seed != null)\n            {\n                if (!state.SeedingCompleted)\n                {\n                    seed(context, state.AnyOperationPerformed);\n                    state.SeedingCompleted = true;\n                }\n            }\n            else if (coreOptionsExtension.AsyncSeeder != null)\n            {\n                throw new InvalidOperationException(CoreStrings.MissingSeeder);\n            }\n\n            state.Transaction?.Commit();\n            return state.AnyOperationPerformed;\n        }\n        finally\n        {\n            state.DatabaseLock?.Dispose();\n            state.DatabaseLock = null;\n            state.Transaction?.Dispose();\n            state.Transaction = null;\n            _connection.Close();\n        }\n    }\n\n    /// <summary>\n    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to\n    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Relational/Migrations/Internal/Migrator.cs#L185-L221","documentation":"Thrown in the synchronous Migrator.Migrate path when `UseAsyncSeeding` was configured but no matching synchronous seed delegate (`UseSeeding`) was supplied. The sync migrate performed a synchronous store operation and then tried to seed synchronously, but only an async seeder exists.","triggerScenarios":"Calling `Database.Migrate()` (synchronous) after configuring only `.UseAsyncSeeding(...)` via `UseSeeding`/`UseAsyncSeeding` options, without a matching `.UseSeeding(...)` delegate.","commonSituations":"Configuring async-only seeding in startup and then a synchronous code path (hosted service, legacy code) calls `Migrate()`; partial migration from sync to async seeding APIs.","solutions":["Provide a synchronous seeder too: call `UseSeeding` with a delegate equivalent to your `UseAsyncSeeding`.","Switch the caller to `MigrateAsync()` so the async seeder is used.","If seeding is not needed for the sync path, remove the `UseAsyncSeeding` registration."],"exampleFix":"// before\noptions.UseSqlServer(cs)\n  .UseAsyncSeeding((ctx, _, ct) => SeedAsync(ctx, ct));\nawait db.Database.MigrateAsync(); // ok\n// someone calls db.Database.Migrate(); // throws\n// after\noptions.UseSqlServer(cs)\n  .UseSeeding((ctx, _) => Seed(ctx))\n  .UseAsyncSeeding((ctx, _, ct) => SeedAsync(ctx, ct));","handlingStrategy":"validation","validationCode":"// If you register an async seeder, also register a sync one before sync Migrate.\nvar core = options.FindExtension<CoreOptionsExtension>();\nif (core?.AsyncSeeder is not null && core?.Seeder is null)\n    throw new InvalidOperationException(\"Register UseSeeding alongside UseAsyncSeeding to support synchronous Migrate.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always register both `UseSeeding` and `UseAsyncSeeding` with equivalent logic.","Prefer `MigrateAsync` in async startup; reserve `Migrate` for genuinely sync hosts and ensure a sync seeder exists."],"tags":["efcore","migrations","seeding","synchronous","relational"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}