How to create new table's in database using IMigrationManager ?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 years ago
Hi
please i have nop v 4.30 and now i need to add 3 tables in database - i try to do it via IMigrationManager but nothing happen and no error but database not has any new table ?

i have did this steps:
1. create class i need in domain folder as example "DirectorsBoard" class.
2. add migration class inside migration folder as code below
    class AddDirectorsBoardTable : AutoReversingMigration
    {
        private readonly IMigrationManager _migrationManager;

        public AddDirectorsBoardTable(IMigrationManager migrationManager)
        {
            _migrationManager = migrationManager;
        }

        /// <summary>Collect the UP migration expressions</summary>
        public override void Up()
        {
            _migrationManager.BuildTable<DirectorsBoard>(Create);
        }
    }


3. now i have add this part of code inside "ApplicationBuilderExtensions.cs" before this line "pluginService.UpdatePlugins();"
                var migrationManager = engine.Resolve<IMigrationManager>();
                migrationManager.ApplyUpMigrations();


4. now i run the project no errors but nothing added to my database ?

so please how i can get this works (hope to know full steps) ?

thanks a lot ...
3 years ago
Hello

Please look into PickupInStore plugin, it can be help you to create table in database.
3 years ago
I followed the same steps except that i added NopMigration attribute and made the class public. I can see the new tables in Database.

[NopMigration("2020/09/18 11:24:16:2551770", "Logistics. Create Tables")]
    public class AddTableLogistics : AutoReversingMigration
    {
        private readonly IMigrationManager _migrationManager;

        public AddTableLogistics(IMigrationManager migrationManager)
        {
            _migrationManager = migrationManager;
        }

        /// <summary>Collect the UP migration expressions</summary>
        public override void Up()
        {
            _migrationManager.BuildTable<Logistic>(Create);
            _migrationManager.BuildTable<LogisticAttribute>(Create);
            _migrationManager.BuildTable<LogisticAttributeValue>(Create);
            _migrationManager.BuildTable<LogisticNote>(Create);
        }
    }
}
3 years ago
I am also new and want to know how to install it.
3 years ago
https://docs.nopcommerce.com/en/developer/plugins/how-to-write-plugin-4.30.html
Use this for create new plugin in nopcommerce.

Also i suggest you please read nopcommerce document, it is help for you.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.