1
이 This Example
에서 오는 나는 데이터 컨텍스트를 가지고EntityCodeFirst + MVC4 WebSecurity = 슬픈 날
public class AggregateContext : DbContext
{
public DbSet<BlogEntry> BlogEntries { get; set; }
public DbSet<UserProfile> UserProfiles { get; set; }
}
그리고 응용 프로그램에서 나는이
Database.SetInitializer(new TestingDbInitializer());
new AggregateContext().UserProfiles.Find(1);
을 시작하고 내 이니셜이
처럼 보인다public class TestingDbInitializer : DropCreateDatabaseAlways<AggregateContext>
{
protected override void Seed(AggregateContext context)
{
AccountsContext(context);
// add a bunch of Lorems to the blog. does call context.SaveChanges();
BlogsContext(context);
}
void AccountsContext(AggregateContext context)
{
WebSecurity.InitializeDatabaseConnection(
"DefaultConnection",
"UserProfile",
"UserId",
"UserName",
autoCreateTables: true);
//create Admin
if (!WebSecurity.ConfirmAccount("Admin"))
{
var confirm = WebSecurity.CreateUserAndAccount(
"Admin",
"password",
new { Email = "[email protected]" });
if (!Roles.RoleExists("Admin"))
Roles.CreateRole("Admin");
Roles.AddUserToRole("Admin", "Admin");
}
}
실행할 때이 줄이 충돌합니다.
var에 확인 = WebSecurity.CreateUserAndAccount ( "관리자", "암호", 새로운 {이메일 = "[email protected]"});
sqlexception과 함께 "잘못된 열 이름 'Email'."
서버 탐색기에서 내 데이터베이스를 보면 이메일 열이 만들어지지 않았 음을 알 수 있습니다.