私はAzureによってホストされている新しいプロジェクトを開始しました - そして、私はそれが自動的にテーブルを作成させようとしています。EntityFramework 6 - テーブルを作成しますか?
私はモデルがあります:
public class Account
{
[Key]
[Required]
public int Id { get; set; }
[Required]
public string Name { get; set; }
[Required]
public string Surname { get; set; }
[Required]
[EmailAddress]
public string Email { get; set; }
}
そして、私のGlobal.asaxの中:
Database.SetInitializer(new CreateDatabaseIfNotExists<ApplicationDbContext>());
をそして、最後にApplicationDbContext:
public class ApplicationUser : IdentityUser
{
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager, string authenticationType)
{
// Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
var userIdentity = await manager.CreateIdentityAsync(this, authenticationType);
// Add custom user claims here
return userIdentity;
}
}
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("DefaultConnection", throwIfV1Schema: false)
{
}
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
public System.Data.Entity.DbSet<Account> Accounts { get; set; }
}
そして、私のプロジェクトを実行した後、それテーブルを作成しません。あるいは私は私が見ていない何か間違っているのですか?
こんにちはKevinさん、あなたの 'DefaultConnection'接続文字列は正しいのですか? – GeorgeChond