{"record":{"id":"7a5bef48a24a904c","repo":"dotnet/efcore","slug":"a-synchronous-store-management-operation-was-perfo","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.Cosmos/Storage/Internal/CosmosDatabaseCreator.cs","lineNumber":258,"sourceCode":"    ///     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 SeedDataAsync(\n        bool created,\n        CancellationToken cancellationToken = default)\n    {\n        var coreOptionsExtension =\n            _contextOptions.FindExtension<CoreOptionsExtension>();\n\n        if (coreOptionsExtension?.AsyncSeeder is not null)\n        {\n            await coreOptionsExtension.AsyncSeeder(_currentContext.Context, created, cancellationToken).ConfigureAwait(false);\n        }\n        else if (coreOptionsExtension?.Seeder is not null)\n        {\n            throw new InvalidOperationException(CoreStrings.MissingSeeder);\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\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 Task<bool> EnsureDeletedAsync(CancellationToken cancellationToken = default)\n        => _cosmosClient.DeleteDatabaseAsync(cancellationToken);\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>","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Cosmos/Storage/Internal/CosmosDatabaseCreator.cs#L240-L276","documentation":"During EnsureCreatedAsync, EF Core calls SeedDataAsync which requires an asynchronous seed delegate (UseAsyncSeeding). If you registered only a synchronous seed delegate via UseSeeding but not an async equivalent, the async seeding path has nothing to invoke and throws (CosmosDatabaseCreator.cs:252-259). Because Cosmos DB only supports async I/O, the sync seeder cannot be used here. The message instructs you to provide both delegates.","triggerScenarios":"Configuring optionsBuilder.UseSeeding((ctx, created) => { ... }) without a matching optionsBuilder.UseAsyncSeeding((ctx, created, ct) => ...), then calling context.Database.EnsureCreatedAsync(). The Cosmos provider's SeedDataAsync checks for AsyncSeeder first; if null but Seeder exists, it throws.","commonSituations":"Following a relational-provider tutorial that only registers UseSeeding and switching to Cosmos. Registering seed logic in only the sync overload during migration to async. Using a shared seeding helper that only provides the sync delegate.","solutions":["Register both delegates with equivalent logic: optionsBuilder.UseSeeding((ctx, created) => SeedData(ctx, created)) and optionsBuilder.UseAsyncSeeding(async (ctx, created, ct) => await SeedDataAsync(ctx, created, ct)).","For Cosmos-only apps, register only UseAsyncSeeding (the async path is what runs).","Ensure the sync and async delegates perform the same seeding work to keep behavior consistent across sync/async entry points."],"exampleFix":"// before\noptionsBuilder.UseSeeding((ctx, created) =>\n{\n    ctx.Blogs.Add(new Blog { Url = \"http://sample.com\" });\n    ctx.SaveChanges();\n});\n\n// after\noptionsBuilder.UseSeeding((ctx, created) =>\n{\n    ctx.Blogs.Add(new Blog { Url = \"http://sample.com\" });\n    ctx.SaveChanges();\n});\noptionsBuilder.UseAsyncSeeding(async (ctx, created, ct) =>\n{\n    ctx.Blogs.Add(new Blog { Url = \"http://sample.com\" });\n    await ctx.SaveChangesAsync(ct);\n});","handlingStrategy":"validation","validationCode":"// After configuring options, verify both seeders are registered when using Cosmos.\nvar coreExt = dbContextOptions.FindExtension<CoreOptionsExtension>();\nif (coreExt?.Seeder is not null && coreExt?.AsyncSeeder is null)\n    throw new InvalidOperationException(\"UseSeeding is set but UseAsyncSeeding is missing; Cosmos requires the async seeder.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always register both UseSeeding and UseAsyncSeeding with equivalent logic.","For Cosmos-only projects, prefer UseAsyncSeeding alone.","Add a startup check that both delegates are present if either is configured."],"tags":["cosmos","seeding","async","configuration"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}