Hello guys,
I just tested upgrading a database from 4.3 to 4.5 directly (using the migrations provided by nopCommerce) but I got the following error:
Unhandled exception. System.AggregateException: One or more errors occurred. (The value '0' is not a valid value for the enum 'ShippingSortingEnum'.)
---> System.ArgumentException: The value '0' is not a valid value for the enum 'ShippingSortingEnum'.
at System.ComponentModel.EnumConverter.ConvertTo(ITypeDescriptorContext context, CultureInfo culture, Object value, Type destinationType)
at System.ComponentModel.TypeConverter.ConvertToString(ITypeDescriptorContext context, CultureInfo culture, Object value)
at System.ComponentModel.TypeConverter.ConvertToInvariantString(Object value)
at Nop.Services.Configuration.SettingService.SetSettingAsync(Type type, String key, Object value, Int32 storeId, Boolean clearCache)
at Nop.Services.Configuration.SettingService.SaveSettingAsync[T](T settings, Int32 storeId)
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at Nop.Web.Framework.Migrations.UpgradeTo440.SettingMigration.Up()
at FluentMigrator.MigrationBase.GetUpExpressions(IMigrationContext context)
at FluentMigrator.Runner.MigrationRunner.<>c.<ApplyMigrationUp>b__69_0(IMigration m, IMigrationContext c)
at FluentMigrator.Runner.MigrationRunner.ExecuteMigration(IMigration migration, Action`2 getExpressions)
at FluentMigrator.Runner.MigrationRunner.ApplyMigrationUp(IMigrationInfo migrationInfo, Boolean useTransaction)
at FluentMigrator.Runner.MigrationRunner.Up(IMigration migration)
at Nop.Data.Migrations.MigrationManager.ApplyUpMigrations(Assembly assembly, MigrationProcessType migrationProcessType)
at Nop.Web.Framework.Infrastructure.Extensions.ApplicationBuilderExtensions.StartEngine(IApplicationBuilder application)
at Program.<Main>$(String[] args)
I think the issue comes from an added property
ShippingSorting in the
Nop.Core.Domain.Shipping.ShippingSettings which wasn't there in 4.4. The
ShippingSettings class is saved by the
Nop.Web.Framework.Migrations.UpgradeTo440.SettingMigration but when you upgrade directly from 4.3 to 4.5 the
ShippingSorting value doesn't exist in the database so it defaults to 0 which isn't a valid value for the
Nop.Core.Domain.Shipping.ShippingSortingEnum and the upgrade fails.
This can be tested easily by creating a sample database in 4.3 and upgrading it directly to 4.5 without running 4.4 code on it.
Most people would upgrade their database directly from 4.3 to 4.5 without running it on 4.4 before that so that would be a big problem for them. I request this to be fixed since this will be a big problem for nopCommerce going forward since version skipping wouldn't work and upgrading your nopCommerce several versions up will be very frustrating having to run your database with the code of each version.
Note: I tested with the NoSource code version of nopCommerce 4.5.
Regards,
Anton