Zylvian
Zylvian
CC#
Created by Zylvian on 5/20/2025 in #help
.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. 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.
5 replies
CC#
Created by Zylvian on 5/16/2025 in #help
✅ Is there a good way to add example input values to your OpenAPI spec?
Is there a good way to add example values to your OpenAPI spec so that e.g my Scalar playground has an example date ready, instead of typing a UTC datetime every time? .NET 9 btw
5 replies