그냥 정규 시드를 사용하지만 컨텍스트가 사용중인 서버를 확인하고 그에 따라 작동하십시오. 어느 화이트리스트 dev에 데이터베이스 또는 블랙리스트 찌르다 서버 : 당신은 또한 당신의 Web.config의 환경을 확인하는 설정을 추가 할 수 있습니다
internal sealed class Configuration : DbMigrationsConfiguration<ApplicationDbContext>
{
protected override void Seed(ApplicationDbContext context)
{
if (context.Database.Connection.DataSource != "ProductionServer")
{
if (!context.MyTable.Any()) // If table is empty, seed it...
{
context.MyTable.AddOrUpdate(
p => p.ID,
new MyTable{ ID = 1, FullName = "Mary Peters" },
new MyTable{ ID = 2, FullName = "Mike Lambson" },
new MyTable{ ID = 3, FullName = "Steve Miller" }
);
}
}
...
}
}
:
if (ConfigurationManager.AppSettings["Environment"] == "DEV")
{
...
}