dotnet/efcore · error · InvalidOperationException
A synchronous store management operation was performed and…
Error message
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'.
What it means
Thrown from SeedDataAsync when an asynchronous seed delegate was not registered but a synchronous one was, yet the async seeding pipeline is being executed. EF Core requires that when you customize seeding you supply both a sync (UseSeeding) and an async (UseAsyncSeeding) delegate, because both the sync and async store pipelines may run. The error tells you to register the matching delegate.
Solutions
- Add a matching UseAsyncSeeding(async (ctx, created, ct) => { ... }) that mirrors the logic in your UseSeeding callback.
- Or, if you only ever run async workflows, switch entirely to UseAsyncSeeding and supply a trivial (or no) sync delegate as required by the framework.
- Ensure both delegates perform the same seeding work so behavior is identical regardless of which pipeline runs.
Example fix
// before
optionsBuilder.UseSeeding((ctx, created) =>
{
ctx.Blogs.Add(new Blog { Url = "http://blogs.msdn.com" });
ctx.SaveChanges();
});
// after
optionsBuilder.UseSeeding((ctx, created) =>
{
ctx.Blogs.Add(new Blog { Url = "http://blogs.msdn.com" });
ctx.SaveChanges();
}).UseAsyncSeeding(async (ctx, created, ct) =>
{
ctx.Blogs.Add(new Blog { Url = "http://blogs.msdn.com" });
await ctx.SaveChangesAsync(ct);
}); Defensive patterns
Strategy: validation
Validate before calling
// In a startup test, assert both seeders are configured together
var ext = dbContext.Options.FindExtension<CoreOptionsExtension>();
if (ext?.Seeder is not null && ext?.AsyncSeeder is null
|| ext?.Seeder is null && ext?.AsyncSeeder is not null)
{
throw new InvalidOperationException("Configure UseSeeding AND UseAsyncSeeding together.");
} Try / catch
try { await dbContext.Database.EnsureCreatedAsync(ct); }
catch (InvalidOperationException ex) when (ex.Message.Contains("UseSeeding"))
{
// add the missing UseAsyncSeeding (or UseSeeding) delegate, then retry.
} Prevention
- Always register UseSeeding and UseAsyncSeeding as a matched pair.
- Add a startup assertion that both (or neither) seeders are configured.
- Keep the bodies of both delegates semantically identical.
When it happens
Trigger: Calling DbContextOptionsBuilder.UseSeeding(...) (sync only) without a matching UseAsyncSeeding(...), then invoking the async store-creation pipeline (EnsureCreatedAsync or the internal async SeedDataAsync on CosmosDatabaseCreator). At CosmosDatabaseCreator.cs:252-258, AsyncSeeder is null and Seeder is non-null, so MissingSeeder is thrown.
Common situations: Following an older seeding tutorial that only mentions UseSeeding. Upgrading EF Core to a version that split seeding into sync/async delegates without adding the async overload. ASP.NET Core startup that only configures the sync delegate but the host calls the async path.
Related errors
- A call was made to ' ' that changed an option that must be…
- A full-text index is defined for
- A full-text index on
- A partition key is defined on entity type
- A synchronous store management operation was performed and…
AI-assisted analysis of dotnet/efcore@3a2006ef56 (2026-08-11).
Data as JSON: /api/errors/7a5bef48a24a904c.
Report an issue: GitHub.
Appendix: source
Thrown at src/EFCore.Cosmos/Storage/Internal/CosmosDatabaseCreator.cs:258
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual async Task SeedDataAsync(
bool created,
CancellationToken cancellationToken = default)
{
var coreOptionsExtension =
_contextOptions.FindExtension<CoreOptionsExtension>();
if (coreOptionsExtension?.AsyncSeeder is not null)
{
await coreOptionsExtension.AsyncSeeder(_currentContext.Context, created, cancellationToken).ConfigureAwait(false);
}
else if (coreOptionsExtension?.Seeder is not null)
{
throw new InvalidOperationException(CoreStrings.MissingSeeder);
}
}
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual Task<bool> EnsureDeletedAsync(CancellationToken cancellationToken = default)
=> _cosmosClient.DeleteDatabaseAsync(cancellationToken);
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>View on GitHub (pinned to 3a2006ef56)