Plugin with data access: 4.30

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 Jahre weitere
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
3 Jahre weitere
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
3 Jahre weitere
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?
3 Jahre weitere
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.
3 Jahre weitere
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!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.