I'm using the new way of seeding data in EF Core 2.1 and I want to seed data for the development environment only.
Initially I tried this:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") != EnvironmentName.Development)
{
return;
}
modelBuilder.Entity<Customer>().HasData(new Customer { ... });
}
However, I noticed that the generated migration will always insert the customers into the database.
Is there a way of restricting the data seed on a per environment basis?