2012-12-12 6 views
1

I가 나는 다음과 같이 약간의 열을 추가하고 싶었 클래스 :코드 첫 번째 마이그레이션

public sealed class Configuration : DbMigrationsConfiguration<DataContext> 
{ 
    public Configuration() 
    { 
     AutomaticMigrationsEnabled = true; 
     AutomaticMigrationDataLossAllowed = true; 
    } 

    protected override void Seed(DataContext context) 
    { 
     // This method will be called after migrating to the latest version. 

     // You can use the DbSet<T>.AddOrUpdate() helper extension method 
     // to avoid creating duplicate seed data. E.g. 
     // 
     // context.People.AddOrUpdate(
     //  p => p.FullName, 
     //  new Person { FullName = "Andrew Peters" }, 
     //  new Person { FullName = "Brice Lambson" }, 
     //  new Person { FullName = "Rowan Miller" } 
     // ); 
     // 
    } 
} 

난 그냥 싶어이 한 번 더 실행하고 있는지 확인 : 여기

public partial class News : DbMigration 
{ 
    public override void Up() 
    { 

     AddColumn("dbo.News", "IsSchool", c => c.Boolean()); 
     AddColumn("dbo.News", "City", c => c.String(maxLength: 200)); 
     AddColumn("dbo.News", "County", c => c.String(maxLength: 200)); 
     AddColumn("dbo.News", "SchoolName", c => c.String(maxLength: 200)); 
     AddColumn("dbo.News", "VisitDatetime", c => c.DateTime()); 

     Sql("UPDATE dbo.News SET IsSchool='false'"); 
    } 

    public override void Down() 
    { 
     DropColumn("dbo.News", "VisitDatetime"); 
     DropColumn("dbo.News", "County"); 
     DropColumn("dbo.News", "City"); 
     DropColumn("dbo.News", "IsSchool"); 
     DropColumn("dbo.News", "SchoolName"); 
    } 
} 

구성입니다 DB가 업데이트됩니까? 마이그레이션을 어떻게 수행 할 수 있습니까?

나는 데이터베이스에 액세스 할 수없는 내 응용 프로그램은 "IsSchool는"추가 라인을 수정 Nullable

답변

3

시도되는 약 IsSchool 필드를 계속 불평

AddColumn("dbo.News", "IsSchool", c => c.Boolean(nullable: false, defaultValue: false)); 
관련 문제