{"record":{"id":"331ad75c3c6c6718","repo":"dotnet/efcore","slug":"a-synchronous-store-management-operation-was-perfo-331ad7","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.InMemory/Storage/Internal/InMemoryDatabaseCreator.cs","lineNumber":82,"sourceCode":"    ///     any release. You should only use it directly in your code with extreme caution and knowing that\n    ///     doing so can result in application failures when updating to a new Entity Framework Core release.\n    /// </summary>\n    public virtual bool EnsureCreated()\n    {\n        var created = Database.EnsureDatabaseCreated();\n\n        var coreOptionsExtension =\n            _contextOptions.FindExtension<CoreOptionsExtension>()\n            ?? new CoreOptionsExtension();\n\n        var seed = coreOptionsExtension.Seeder;\n        if (seed != null)\n        {\n            seed(_currentContext.Context, created);\n        }\n        else if (coreOptionsExtension.AsyncSeeder != null)\n        {\n            throw new InvalidOperationException(CoreStrings.MissingSeeder);\n        }\n\n        return created;\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\n    ///     any release. You should only use it directly in your code with extreme caution and knowing that\n    ///     doing so can result in application failures when updating to a new Entity Framework Core release.\n    /// </summary>\n    public virtual async Task<bool> EnsureCreatedAsync(CancellationToken cancellationToken = default)\n    {\n        var created = Database.EnsureDatabaseCreated();\n\n        var coreOptionsExtension =\n            _contextOptions.FindExtension<CoreOptionsExtension>()\n            ?? new CoreOptionsExtension();","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.InMemory/Storage/Internal/InMemoryDatabaseCreator.cs#L64-L100","documentation":"InMemoryDatabaseCreator.EnsureCreated (the synchronous path) looks up the CoreOptionsExtension's Seeder delegate. If Seeder is null but AsyncSeeder was provided (i.e. the user configured only UseAsyncSeeding), the sync code path has nothing to call and throws MissingSeeder. EF Core requires that if you seed data you provide both a sync and an async delegate, because the framework calls whichever matches the EnsureCreated/EnsureCreatedAsync method invoked.","triggerScenarios":"Configuring a model with UseAsyncSeeding(...) but not UseSeeding(...), then calling EnsureCreated() (synchronous). The creator finds no sync seeder and throws. Also triggered internally when EF Core calls the sync seed path during model finalization or migration.","commonSituations":"Setting up data seeding via UseAsyncSeeding in OnModelCreating or DbContextOptions but forgetting to add the sync equivalent. Calling context.Database.EnsureCreated() in a synchronous startup path (e.g. a console Main or a sync initializer). Migrating code that previously used only async seeding to a context where sync EnsureCreated is called.","solutions":["Add UseSeeding with a delegate equivalent to the one supplied in UseAsyncSeeding.","Call EnsureCreatedAsync() instead of EnsureCreated() so the async seed delegate is used.","Provide both UseSeeding and UseAsyncSeeding delegates to cover both sync and async paths."],"exampleFix":"// before — only async seeding configured\noptions.UseInMemoryDatabase(\"db\")\n      .UseAsyncSeeding((ctx, created, ct) => SeedAsync(ctx, ct));\n// then later: ctx.Database.EnsureCreated();  // throws\n\n// after — provide both sync and async seeders\noptions.UseInMemoryDatabase(\"db\")\n      .UseSeeding((ctx, created) => Seed(ctx))\n      .UseAsyncSeeding((ctx, created, ct) => SeedAsync(ctx, ct));","handlingStrategy":"validation","validationCode":"// Validate at startup: if AsyncSeeder is configured, ensure Seeder is too.\nvar coreExt = contextOptions.FindExtension<CoreOptionsExtension>();\nif (coreExt?.AsyncSeeder != null && coreExt?.Seeder == null)\n{\n    throw new InvalidOperationException(\n        \"UseSeeding must be configured when UseAsyncSeeding is set, \" +\n        \"because EnsureCreated() requires the sync seeder.\");\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    context.Database.EnsureCreated();\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"seed delegate\"))\n{\n    // Either add UseSeeding or switch to EnsureCreatedAsync\n    await context.Database.EnsureCreatedAsync(cancellationToken);\n}","preventionTips":["Always configure both UseSeeding and UseAsyncSeeding when using data seeding.","If only async seeding is needed, always call EnsureCreatedAsync().","Add a startup validation check that verifies both seeders are present.","Document the sync/async seeding contract in your DbContext setup."],"tags":["efcore","inmemory","seeding","configuration","sync-async"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}