How to seed data conditionally depending on environment?
- Use IHostingEnvironment or config flags inside the DbContext
OnModelCreating or after migration.
- Separate seed classes or methods per environment.
- Use EF Core’s HasData method or custom seed logic at runtime.