I have started a new project which is hosted by Azure - and I am trying to let it create the tables automatically.
I have a model:
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; }
}
And in my Global.asax:
Database.SetInitializer(new CreateDatabaseIfNotExists<ApplicationDbContext>());
And, finally the 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; }
}
And after running my project, it does not create the tables. Or am I doing something wrong which I'm not seeing?
DefaultConnectionconnection string correct?