title: Seeding data for a particular environment in Entity Framework Core 2.1
body: <p>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.</p>
  
  <p>Initially I tried this:</p>
  
  <pre><code>protected override void OnModelCreating(ModelBuilder modelBuilder)
  {
      if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") != EnvironmentName.Development)
      {
          return;
      }
  
      modelBuilder.Entity&lt;Customer&gt;().HasData(new Customer { ... });
  }
  </code></pre>
  
  <p>However, I noticed that the generated migration will always insert the customers into the database.</p>
  
  <p>Is there a way of restricting the data seed on a per environment basis?</p>