Today I upgraded my solution from EPiServer Commerce 12.3 to 12.4. During execution of the "migrate target markets" migration step, I got the following error message:
Update promotion priority failed with exception 'System.ComponentModel.DataAnnotations.ValidationException: The valid from date cannot be empty. at EPiServer.Core.ContentProvider.ThrowValidationException(ICollection`1 errors) at EPiServer.Core.ContentProvider.Validate(IContent content, ContentSaveValidationContext saveValidationContext) at EPiServer.Core.Internal.DefaultContentRepository.Save(IContent content, SaveAction action, AccessLevel access) at EPiServer.Commerce.Internal.Migration.Steps.MigrateTargetMarketsStep.MigrateTargetMarket(SalesCampaign campaign) at EPiServer.Commerce.Internal.Migration.Steps.MigrateTargetMarketsStep.Execute(IProgressMessenger progressMessenger)'.
As far as my understanding goes, there is supposedly a data issue with one of the sales campaigns. However, manually checking in the tblContentProperty tables did not give me any odd results for any sales campaigns currently in the system. Re-running and restarting the web application did not resolve the issue either. I've temporarily disabled the migration step by setting it as completed in tblBigTable.
Luckily this was not on a production environment :-)
Is this a known issue?
No this is not a known issue. It is very strange - I would suggest you to contact our developer support so we can look into this. Thanks
One workaround is to create an instance of IMigrateStep, with SortOrder = 1549. Well technically IMigrateStep is an internal interface, but because you even accessed database directly, so that should be no problem for you. Inside Execute method you can try to load campaigns and foreach each of them. With a debugger you can find out which campaign is problematic and even fix it.
We recommend against skipping migration steps
Thanks for your insights, Quan Mai! After a good night's sleep we've had a fresh look at this.
We built a custom MigrationStep as per your suggestion, and used it to investigate which SalesCampaign had an invalid ValidFrom date. As it turned out, there was indeed one - it was set to 01/01/0001 00:00, i.e. a DateTime's MinValue. We didn't see this yesterday when looking in the database (probably due to a bad JOIN :-) ).
Upon further investigation we've been able to identify the root cause. It can be reproduced as follows:
When the MigrationStep is subsequently executed, the validator which runs during saving refuses to save the entity as it does not have a valid ValidFrom date.
P.S. we re-enabled the migration step, and it has now executed successfully after removing the rogue sales campaign.
Good work on the trouble shooting!
I think I'll go ahead and register a bug for this. We should look into if we can make the migration step should be a bit more graceful in handling "unexpected" data.
I see that this issue has been fixed in Commerce 12.4.1. Thanks for the quick turnaround :)