Skip to content

Instantly share code, notes, and snippets.

@executeautomation
Created August 15, 2021 10:24
Show Gist options
  • Select an option

  • Save executeautomation/f6e2f39aeb46525b67854a524c2b68b4 to your computer and use it in GitHub Desktop.

Select an option

Save executeautomation/f6e2f39aeb46525b67854a524c2b68b4 to your computer and use it in GitHub Desktop.
if (args.Length == 1 && args[0].ToLower() == "seeddata")
SeedData(app);
//Seed Data
void SeedData(IHost app)
{
var scopedFactory = app.Services.GetService<IServiceScopeFactory>();
using (var scope = scopedFactory.CreateScope())
{
var service = scope.ServiceProvider.GetService<DataSeeder>();
service.Seed();
}
}
@Codingjames

Copy link
Copy Markdown

Hello I reading your article
https://medium.com/executeautomation/seeding-data-using-ef-core-in-asp-net-core-6-0-minimal-api-d5f6ecdb350c

I want to know line 2. why it can get app where app you declare.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment