<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/seeding-data-with-ef-core-9-obsxhqnt4" -->

---
title: Seeding Data with EF Core 9 | daily.dev
description: EF Core 9 introduces UseSeeding and UseAsyncSeeding methods for configuring database seed data directly through DbContext options, offering a more flexible...
canonical: https://daily.dev/posts/seeding-data-with-ef-core-9-obsxhqnt4
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Seeding Data with EF Core 9 | daily.dev
og:description: EF Core 9 introduces UseSeeding and UseAsyncSeeding methods for configuring database seed data directly through DbContext options, offering a more flexible...
og:url: https://daily.dev/posts/seeding-data-with-ef-core-9-obsxhqnt4
og:image: https://api.daily.dev/og/posts/oBsxhqNt4.png
og:image:alt: Seeding Data with EF Core 9
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Seeding Data with EF Core 9

**[NikolaTech](https://daily.dev/sources/nikolatech)** · 4 min read · 0 upvotes · 0 comments

## Summary

EF Core 9 introduces UseSeeding and UseAsyncSeeding methods for configuring database seed data directly through DbContext options, offering a more flexible alternative to the previous model-managed or migration-based seeding approaches. The post walks through setting up a .NET 9 Product API, generating fake data with Bogus, and triggering seeding via EnsureCreated or EnsureCreatedAsync, noting that mixing sync and async methods will silently prevent seeding from running. It also recommends isolating seeding into a separate process for production to avoid concurrency issues.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://nikolatech.net/blogs/ef-core-seeding-asp-dotnet-core>

## Questions this post answers

### How do I seed database data using EF Core 9's UseSeeding and UseAsyncSeeding methods?

Configure UseSeeding or UseAsyncSeeding inside AddDbContext options when setting up the DbContext, writing normal C# code that checks if data already exists and inserts it if not. UseSeeding runs synchronously and is triggered by EnsureCreated(), while UseAsyncSeeding runs asynchronously and is triggered by EnsureCreatedAsync(); mixing the sync and async pairs prevents the seeding logic from running.

_Developers wiring up EF Core 9 seeding logic can find implementation walkthroughs like this on daily.dev._

### What are the different ways to seed data in EF Core?

EF Core supports four approaches to seeding data: custom initialization logic, model-managed data, manual migrations, and data seeding through configuration options. The configuration options approach, added in EF Core 9 via UseSeeding and UseAsyncSeeding, lets you write arbitrary C# code including database queries during the seeding process, making it more flexible than the older model-managed seeding.

_daily.dev surfaces comparisons like this for developers deciding how to structure EF Core seeding._

### Why isn't my EF Core UseAsyncSeeding logic running when I call EnsureCreated?

EnsureCreated() only triggers the synchronous UseSeeding method, while EnsureCreatedAsync() only triggers UseAsyncSeeding; calling the wrong pair means the seeding logic never executes. Always match EnsureCreated() with UseSeeding and EnsureCreatedAsync() with UseAsyncSeeding to ensure the configured seed logic actually runs.

_Developers debugging silent EF Core seeding failures can track gotchas like this on daily.dev._

## Similar posts on daily.dev

- [EF Core Performance Best Practices in .NET 10](https://daily.dev/posts/ef-core-performance-best-practices-in-net-10-syq7fm9cv) · We Are .NET · 55 upvotes · 4 comments
- [30 EF Core Interview Questions That Actually Get Asked in 2026](https://daily.dev/posts/30-ef-core-interview-questions-that-actually-get-asked-in-2026-o0xkf1r0a) · Code with Mukesh · 5 upvotes · 0 comments
- [Creating a Production-Ready CRUD Application in ASP.NET Core](https://daily.dev/posts/creating-a-production-ready-crud-application-in-asp-net-core-1mfpkrepl) · Telerik · 0 upvotes · 0 comments
- [Persisting a Rich Domain Model With EF Core](https://daily.dev/posts/persisting-a-rich-domain-model-with-ef-core-dqvtlqgt5) · Milan Jovanović · 42 upvotes · 1 comments

---

Tags: [#.net](https://daily.dev/tags/.net), [#c#](https://daily.dev/tags/c#)

[View this post on daily.dev](https://daily.dev/posts/seeding-data-with-ef-core-9-obsxhqnt4)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Seeding Data with EF Core 9","url":"https://daily.dev/posts/seeding-data-with-ef-core-9-obsxhqnt4","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/seeding-data-with-ef-core-9-obsxhqnt4"},"datePublished":"2026-10-04T13:05:53.678Z","dateModified":"2026-10-04T13:14:00.318Z","description":"EF Core 9 introduces UseSeeding and UseAsyncSeeding methods for configuring database seed data directly through DbContext options, offering a more flexible...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/ef20ac4a94e9dc9c98db468a4b226144?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/ef20ac4a94e9dc9c98db468a4b226144?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"NikolaTech","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"NikolaTech","logo":"https://media.daily.dev/image/upload/s--1h2fO6FL--/f_auto,q_auto/v1791119050/logos/nikolatech?_a=BAMAMicg0","url":"https://daily.dev/sources/nikolatech"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/seeding-data-with-ef-core-9-obsxhqnt4","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":".net,c#","timeRequired":"PT4M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"NikolaTech","item":"https://daily.dev/sources/nikolatech"},{"@type":"ListItem","position":3,"name":"Seeding Data with EF Core 9"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/seeding-data-with-ef-core-9-obsxhqnt4#faq","mainEntity":[{"@type":"Question","name":"How do I seed database data using EF Core 9's UseSeeding and UseAsyncSeeding methods?","acceptedAnswer":{"@type":"Answer","text":"Configure UseSeeding or UseAsyncSeeding inside AddDbContext options when setting up the DbContext, writing normal C# code that checks if data already exists and inserts it if not. UseSeeding runs synchronously and is triggered by EnsureCreated(), while UseAsyncSeeding runs asynchronously and is triggered by EnsureCreatedAsync(); mixing the sync and async pairs prevents the seeding logic from running. Developers wiring up EF Core 9 seeding logic can find implementation walkthroughs like this on daily.dev."}},{"@type":"Question","name":"What are the different ways to seed data in EF Core?","acceptedAnswer":{"@type":"Answer","text":"EF Core supports four approaches to seeding data: custom initialization logic, model-managed data, manual migrations, and data seeding through configuration options. The configuration options approach, added in EF Core 9 via UseSeeding and UseAsyncSeeding, lets you write arbitrary C# code including database queries during the seeding process, making it more flexible than the older model-managed seeding. daily.dev surfaces comparisons like this for developers deciding how to structure EF Core seeding."}},{"@type":"Question","name":"Why isn't my EF Core UseAsyncSeeding logic running when I call EnsureCreated?","acceptedAnswer":{"@type":"Answer","text":"EnsureCreated() only triggers the synchronous UseSeeding method, while EnsureCreatedAsync() only triggers UseAsyncSeeding; calling the wrong pair means the seeding logic never executes. Always match EnsureCreated() with UseSeeding and EnsureCreatedAsync() with UseAsyncSeeding to ensure the configured seed logic actually runs. Developers debugging silent EF Core seeding failures can track gotchas like this on daily.dev."}}]}
```

