Plugin with data access: 4.30

5 months ago
HI

I am new to NOP as of today.   I have started making some plugins and require them to have data access in order to create some new tables.

However the instructions refer to EF Core.   and EF core is not being used.
And also that some things are supposed to be easier.

So I was wondering if anyone could point me in the right direction of What instructions not to follow.   Or maybe even an upgrade guide, for if someone has done plugins and now needs to upgrade them to use 4.30.

I can then at least reverse engineer the tutorial using that info.

Thanks
5 months ago
I'm not sure if this is the best way of doing that, but it works:


    [NopMigration("2020/04/27 06:00:00", "Widgets.YourWidget base schema")]
    public class SchemaMigration : AutoReversingMigration
    {
        #region Fields

        protected IMigrationManager _migrationManager;

        #endregion

        #region Ctor

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

        #endregion

        #region Methods

        /// <summary>
        /// Collect the UP migration expressions
        /// </summary>
        public override void Up()
        {
            _migrationManager.BuildTable<YourClass1>(Create);
            _migrationManager.BuildTable<YourClass2>(Create);
            Create.ForeignKey()
                .FromTable(nameof(YourClass2)).ForeignColumn(nameof(YourClass2.YourClass1ID))
                .ToTable(nameof(YourClass1)).PrimaryColumn(nameof(YourClass1.Id));
        }

        #endregion
    }


Where `YourClass1` and `YourClass1` are simple DTO objects
4 months ago
But what about the dateTime parameter of NopMigration like:
NopMigration("2020/03/25 12:00:00", "Widgets.FacebookPixel base schema")


How should we determine which dateTime we need to use here?
4 months ago
I belive it is for Migration attribute from FluentMigrator.
It is used to version and order of your DB migrations.

In that case, if you are creating pluggin for one database version, it doesn't matter what you will put there, just put some date, f.e. when your class was created.
4 months ago
titolr10 wrote:
I belive it is for Migration attribute from FluentMigrator.
It is used to version and order of your DB migrations.

In that case, if you are creating pluggin for one database version, it doesn't matter what you will put there, just put some date, f.e. when your class was created.


Thank you for your suggestion!