이 질문은 중복되었습니다. 한 가지 해결책을 찾았지만 4 년이 지난 질문입니다. EntityFramework는 다른 수준에서 나는이 질문을 다시하고 싶다. 여기에 내가 발견하고 실체에 프레임 워크 5.0을 적용하려고하지만 여기Getting Error "데이터베이스가 생성 된 후 'DBContext'컨텍스트를 지원하는 모델이 변경되었습니다."
The model backing the <Database> context has changed since the database was created
작동하지 않습니다 대답은 내 엔티티 모델 클래스 처음이
public class Student
{
public int StudentId {get; set;}
[StringLength(250),Required]
public string StudentName {get; set;}
[StringLength(20),Required]
public string Standard {get; set; }
[StringLength(250),Required]
public string Address {get; set; }
[StringLength(250),Required]
public string Emailid {get; set; }
[StringLength(12),Required]
public string Phoneno {get; set; }
}
와 두 번째 모델 클래스입니다입니다 이
public class Marks
{
public int MarksID { get; set; }
public int StudentId { get; set; }
public int English { get; set; }
public int Maths { get; set; }
public int Science { get; set; }
public int SocialStudy { get; set; }
public int Hindi { get; set; }
public int Total { get; set; }
public Student student { get; set; }
}
이 내 상황에 맞는 클래스입니다
,public class DBContext:DbContext
{
public DBContext()
{
Database.SetInitializer<DbContext>(new DropCreateDatabaseAlways<DbContext>());
}
public DbSet<Student> TbStudent { get; set; }
public DbSet<Marks> TbMarks { get; set; }
}
는이 코드와 데이터베이스가 생성 된 이후 'DBContext'컨텍스트를 백업 모델이 변경
이 오류를 가져 오기를 실행합니다. 코드 첫 번째 마이그레이션을 사용하여 데이터베이스를 업데이트하는 것을 고려하십시오 (http://go.microsoft.com/fwlink/?LinkId=238269).
이
흠, 질문에 첫 번째 마이그레이션 자습서 코드 링크가 있습니다. 읽어 봤니? –