© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•9mo ago•
4 replies
Zylvian

.NET 9 - EF Core + Aspire - Database seeding

I've been looking into different ways to seed our database, and there are a lot of conflicting information.
I have a .NET Aspire project, with a BackendService and a MigrationService. I want to seed a bunch of test data into the database if it's not present. I want to do this through EF and not write SQL scripts.

The EF recommendation is using UseAsyncSeeding (as well as UseSeeding?):
https://learn.microsoft.com/en-us/ef/core/modeling/data-seeding#configuration-options-useseeding-and-useasyncseeding-methods

The .NET Aspire docs simply have this:
https://learn.microsoft.com/en-us/ef/core/modeling/data-seeding#configuration-options-useseeding-and-useasyncseeding-methods

I would like for the logic to be seperated from the BackendService, and potentially be an extra worker service that simply adds data to the database, from entities like
SessionEntity
SessionEntity
.

Any good repos with examples on how to properly do the seeding? The EF recommendation seems extremely wordy in it's implementation, and I'd like for it to be easy to add to a list of entites you want to seed.
Data Seeding - EF Core
Using data seeding to populate a database with an initial set of data using Entity Framework Core
Data Seeding - EF Core
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Aspire + EF Core
C#CC# / help
3y ago
✅ Aspire EF Core Migrations - Deployment to Azure?
C#CC# / help
3mo ago
.Net Aspire
C#CC# / help
15mo ago
❔ Polymorphic relationships in EF Core / .NET Core
C#CC# / help
3y ago