EntityFramework Code first migrations not running after deploying to Azure RRS feed

  • Question

  • I'm developing a web application in ASP.NET using code first migrations. It works fine locally but after deploying to Azure, code first migrations are not executed. I have been following an official .net tutorial step by step a few times but I have not been able to spot what is wrong on my setup. Here is the relevant code:

    DB Context:
    public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
            public ApplicationDbContext() : base("DefaultConnection", throwIfV1Schema: false) {}
            public DbSet<BC_Instance> BiocloudInstances { get; set; }
            static ApplicationDbContext() {}
            public static ApplicationDbContext Create()
                return new ApplicationDbContext();
            protected override void OnModelCreating(DbModelBuilder modelBuilder)
                var conv = new AttributeToTableAnnotationConvention<SoftDeleteAttribute, string>(
                   (type, attributes) => attributes.Single().ColumnName);

    Connection strings:
    (it is replaced on publish, but just in case)
    <add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=bcplatform2;Integrated Security=True;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" /></connectionStrings>

    Code First Migrations configuration
    internal sealed class Configuration : DbMigrationsConfiguration<bcplatform2.Models.ApplicationDbContext>
            public Configuration()
                AutomaticMigrationsEnabled = false;
            protected override void Seed(bcplatform2.Models.ApplicationDbContext context)
                var userManager = new ApplicationUserManager(new UserStore<ApplicationUser>(context));
                var roleManager = new ApplicationRoleManager(new RoleStore<ApplicationRole>(context));
                const string name = "";
                const string password = "Admin@123456";
                const string adminRole = "canruletheworld";
                string[] roles = new string[] { adminRole, ApplicationRole.DefaultRoleName };
                foreach (string role in roles)
                    if (!context.Roles.Any(r => r.Name == role))
                        roleManager.CreateAsync(new ApplicationRole(role));
                if (!context.Users.Any(u => u.UserName == name))
                    var user = new ApplicationUser { UserName = name, Email = name, credit = 10 };
                    userManager.Create(user, password);
                    userManager.AddToRole(user.Id, adminRole);
                    userManager.SetLockoutEnabled(user.Id, false);

    Publication wizard
    I have "Execute Code First Migrations" checked.
    Friday, February 5, 2016 2:43 PM

All replies