nopSolutions / nopCommerce

ASP.NET Core eCommerce software. nopCommerce is a free and open-source shopping cart.
https://www.nopcommerce.com
Other
9.19k stars 5.28k forks source link

Unable to modify store entity due to dependency on store entity prior to migration #5035

Closed DanCRichards closed 2 years ago

DanCRichards commented 4 years ago

More detailed explanation

During startup, the configuration requires access to the store entity. If a user were to adjust the store entity a SQL Column not found error will be thrown. This occurs prior to the UpMigration specified within the StartEngine() method.

nopCommerce version:

4.3

Steps to reproduce the problem:

Using the update-existing-entity tutorial to update the store entity.

  1. Update nop.Core domain
  2. Update nop.Data builder
  3. Add nop.Data migration
  4. Add IMigrationManager.ApplyUpMigration code to ApplicationBuilderExtensions.StartEngine();

Within the DependencyRegistrar.BuildRegistration() there is a call to the store entity. Because the user is updating the store entity the system requires the column which is yet to be updated and a SQL error occurs.

How to solve:

  1. Change the tutorial so that the migration is done prior to store access.
  2. Add some form of checking to see if the store needs migration and do so.
  3. For users, add the lines required on StartEngine() to the BuildRegistration() method and incorporate the namespace as per Visual Studio.

For the future:

Are other entities accessed prior to the migration? - I see a lot of users having issues with not being able to update their entities.

exileDev commented 2 years ago

Closed #5035