Db auto migration problem from 4.5 to 4.6

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
1 year ago
Hello,

I am try to Upgrade from 4.50 to 4.60 but customer migration is not working.
I have only 88 Customer in my Customer table.

once I will start the project I am get invalid column and that all are in customer table.
1 year ago
What is the error?
1 year ago
Hi Raju,
this is the error............


info: FluentMigrator.Runner.MigrationRunner[1000]
      DataMigration migrating
info: FluentMigrator.Runner.Processors.SqlServer.SqlServer2016Processor[1004]
      Beginning Transaction
info: FluentMigrator.Runner.Processors.SqlServer.SqlServer2016Processor[1003]
      BEGIN TRANSACTION
info: FluentMigrator.Runner.Processors.SqlServer.SqlServer2016Processor[1004]
      Rolling back transaction
info: FluentMigrator.Runner.Processors.SqlServer.SqlServer2016Processor[1003]
      ROLLBACK TRANSACTION
Unhandled exception. System.AggregateException: One or more errors occurred. (Invalid column name 'TaxDisplayTypeId'.
Invalid column name 'LanguageId'.
Invalid column name 'CurrencyId'.
Invalid column name 'CustomCustomerAttributesXML'.
Invalid column name 'TimeZoneId'.
Invalid column name 'VatNumberStatusId'.
Invalid column name 'VatNumber'.
Invalid column name 'Fax'.
Invalid column name 'Phone'.
Invalid column name 'StateProvinceId'.
Invalid column name 'CountryId'.
Invalid column name 'County'.
Invalid column name 'City'.
Invalid column name 'ZipPostalCode'.
Invalid column name 'StreetAddress2'.
Invalid column name 'StreetAddress'.
Invalid column name 'Company'.
Invalid column name 'DateOfBirth'.
Invalid column name 'Gender'.
Invalid column name 'LastName'.
Invalid column name 'FirstName'.)
---> Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid column name 'TaxDisplayTypeId'.
Invalid column name 'LanguageId'.
Invalid column name 'CurrencyId'.
Invalid column name 'CustomCustomerAttributesXML'.
Invalid column name 'TimeZoneId'.
Invalid column name 'VatNumberStatusId'.
Invalid column name 'VatNumber'.
Invalid column name 'Fax'.
Invalid column name 'Phone'.
Invalid column name 'StateProvinceId'.
Invalid column name 'CountryId'.
Invalid column name 'County'.
Invalid column name 'City'.
Invalid column name 'ZipPostalCode'.
Invalid column name 'StreetAddress2'.
Invalid column name 'StreetAddress'.
Invalid column name 'Company'.
Invalid column name 'DateOfBirth'.
Invalid column name 'Gender'.
Invalid column name 'LastName'.
Invalid column name 'FirstName'.
   at Microsoft.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__208_0(Task`1 result)
   at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
   at LinqToDB.Data.DataConnection.ExecuteReaderAsync(CommandBehavior commandBehavior, CancellationToken cancellationToken)
   at LinqToDB.Data.DataConnection.ExecuteDataReaderAsync(CommandBehavior commandBehavior, CancellationToken cancellationToken)
   at LinqToDB.Data.DataConnection.ExecuteDataReaderAsync(CommandBehavior commandBehavior, CancellationToken cancellationToken)
   at LinqToDB.Data.DataConnection.QueryRunner.ExecuteReaderAsync(CancellationToken cancellationToken)
   at LinqToDB.Linq.QueryRunner.ExecuteQueryAsync[T](Query query, IDataContext dataContext, Mapper`1 mapper, Expression expression, Object[] ps, Object[] preambles, Int32 queryNumber, Func`2 func, TakeSkipDelegate skipAction, TakeSkipDelegate takeAction, CancellationToken cancellationToken)
   at LinqToDB.Linq.QueryRunner.ExecuteQueryAsync[T](Query query, IDataContext dataContext, Mapper`1 mapper, Expression expression, Object[] ps, Object[] preambles, Int32 queryNumber, Func`2 func, TakeSkipDelegate skipAction, TakeSkipDelegate takeAction, CancellationToken cancellationToken)
   at LinqToDB.Linq.ExpressionQuery`1.GetForEachAsync(Action`1 action, CancellationToken cancellationToken)
   at LinqToDB.AsyncExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken token)
   at System.Linq.AsyncIQueryableExtensions.ToPagedListAsync[T](IQueryable`1 source, Int32 pageIndex, Int32 pageSize, Boolean getOnlyTotalCount)
ClientConnectionId:afe13bdb-ac22-42c7-97f9-527f233795b8
Error Number:207,State:1,Class:16
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at Nop.Data.Migrations.UpgradeTo460.DataMigration.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, Boolean commitVersionOnly)
   at Nop.Web.Framework.Infrastructure.Extensions.ApplicationBuilderExtensions.StartEngine(IApplicationBuilder application)
   at Program.<Main>$(String[] args)
1 year ago
Have you ran customer_data_migrate.sql as per the readme?

https://github.com/nopSolutions/nopCommerce/tree/release-4.60.0/upgradescripts/4.50-4.60
1 year ago
yes, I know that.
but the readme.txt suggest this.
If your database has a lot of "Customer" records, auto migration (during the first application start) can take a long time, so we have prepared scripts to update the database.

if I have only 18 customers on my DB then also this step is required.
My question is auto migration will not work?
1 year ago
Hello,

Yes, That  auto migration does not work. reason behind it, nopCommerce  SchemaMigration.cs class run after DataMigration.cs class.
So, Here you have to set date time in DataMigration.cs file migration.
Then it is work properly.
1 year ago
SagarKayasth wrote:
So, Here you have to set date time in DataMigration.cs file migration.

Are you referring to this line of code?
 [NopMigration("2022-02-03 00:00:00", "4.60.0", UpdateMigrationType.Data, MigrationProcessType.Update)]

If so, what value do you need to set the date and time to?
1 year ago
Hi
You can set any dynamic date time, but not the exact same because if it is the same, it will skip that so add any dynamic date time
1 year ago
Thanks Ilyas. I found a commit made on January 9 that changed the code to read as follows:
 [NopMigration("2022-07-20 00:00:01", "4.60.0", UpdateMigrationType.Data, MigrationProcessType.Update)]

After making the change locally I completed the migration successfully.
1 year ago
Hi. Yes, unfortunately we made such an inaccuracy. I did the analysis and found the historical sequence that led to this situation. We will try to restore the correct order for these two migrations in the next minor version (if it is released). In version 4.70, this problem will not be, since we have refactored the migration system and all migrations that change the structure of the database will now be performed before all others.

bellevuehobby wrote:
Thanks Ilyas. I found a commit made on January 9 that changed the code to read as follows:
 [NopMigration("2022-07-20 00:00:01", "4.60.0", UpdateMigrationType.Data, MigrationProcessType.Update)]

After making the change locally I completed the migration successfully.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.