In my plugin uninstallation, the database update successfully(remove [myTable]). But on the plugin installation, the database not update automatically(not generate [myTable]). Please help me to find problem.
internal sealed class Configuration : DbMigrationsConfiguration<myStoreObjectContext> { public Configuration() { AutomaticMigrationsEnabled = false; MigrationsDirectory = @"Data\Migrations"; ContextKey = "ArvinTech.myStore"; } protected override void Seed(myStoreObjectContext context) { } }
public class myStoreObjectContext : ObjectContextBase { public const string ALIASKEY = "sm_object_context_my_store_zip"; static myStoreObjectContext() { var initializer = new MigrateDatabaseInitializer<myStoreObjectContext, Configuration> { TablesToCheck = new[] { "myFeature" } }; Database.SetInitializer(initializer); } /// <summary> /// For tooling support, e.g. EF Migrations /// </summary> public myStoreObjectContext() : base() { } public myStoreObjectContext(string nameOrConnectionString) : base(nameOrConnectionString, ALIASKEY) { } protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Configurations.Add(new myFeatureMap()); base.OnModelCreating(modelBuilder); } }
public partial class Initial : DbMigration { public override void Up() { if (DbMigrationContext.Current.SuppressInitialCreate<myStoreObjectContext>()) return; CreateTable( "dbo.myFeature", c => new { Id = c.Int(nullable: false, identity: true), Name = c.String(nullable: false, maxLength: 400), FullName = c.String(maxLength: 400), Description = c.String(), Alias = c.String(maxLength: 100), Published = c.Boolean(nullable: false), Deleted = c.Boolean(nullable: false), DisplayOrder = c.Int(nullable: false), CreatedOnUtc = c.DateTime(nullable: false), UpdatedOnUtc = c.DateTime(nullable: false), }) .PrimaryKey(t => t.Id); } public override void Down() { DropTable("dbo.myFeature"); } }
Thanks