SqlException in DataMigration from 4.30 to 4.40.3

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Il y a 2 ans
Hello,

I'm getting the following error trying to migrate from 4.30 to 4.40.3 using nopCommerce_4.40.3_NoSource_win_x64.zip:

info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[58]
      Creating key {39acf374-749e-4510-a74a-7e762e5ebc82} with creation date 2021-04-29 12:12:38Z, activation date 2021-04-29 12:12:38Z, and expiration date 2021-07-28 12:12:38Z.
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
      No XML encryptor configured. Key {39acf374-749e-4510-a74a-7e762e5ebc82} may be persisted to storage in unencrypted form.
info: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[39]
      Writing data to file 'D:\HostingSpaces\adi_lazar\e-naturale.ro\wwwroot\App_Data\DataProtectionKeys\key-39acf374-749e-4510-a74a-7e762e5ebc82.xml'.
info: System.Net.Http.HttpClient.default.LogicalHandler[100]
      Start processing HTTP request POST http://www.materiale-renovare.ro/scheduletask/runtask
info: System.Net.Http.HttpClient.default.LogicalHandler[100]
      Start processing HTTP request POST http://www.materiale-renovare.ro/scheduletask/runtask
info: System.Net.Http.HttpClient.default.LogicalHandler[100]
      Start processing HTTP request POST http://www.materiale-renovare.ro/scheduletask/runtask
info: System.Net.Http.HttpClient.default.ClientHandler[100]
      Sending HTTP request POST http://www.materiale-renovare.ro/scheduletask/runtask
info: System.Net.Http.HttpClient.default.ClientHandler[100]
      Sending HTTP request POST http://www.materiale-renovare.ro/scheduletask/runtask
info: System.Net.Http.HttpClient.default.ClientHandler[100]
      Sending HTTP request POST http://www.materiale-renovare.ro/scheduletask/runtask
info: FluentMigrator.Runner.MigrationRunner[1000]
      637273440000000005: 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
crit: Microsoft.AspNetCore.Hosting.Diagnostics[6]
      Application startup exception
      System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near the keyword 'EXISTS'.
      Incorrect syntax near ','.
         at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
         at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
         at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
         at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
         at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
         at System.Data.SqlClient.SqlDataReader.get_MetaData()
         at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
         at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
         at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite, String method)
         at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
         at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
         at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
         at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
         at LinqToDB.Data.DataConnection.ExecuteReader(IDbCommand command, CommandBehavior commandBehavior)
         at LinqToDB.Data.DataConnection.ExecuteReader(CommandBehavior commandBehavior)
         at LinqToDB.Data.DataConnection.ExecuteReader()
         at LinqToDB.Data.DataConnection.QueryRunner.ExecuteReader()
         at LinqToDB.DataContext.QueryRunner.ExecuteReader()
         at LinqToDB.Linq.QueryRunner.ExecuteElement[T](Query query, IDataContext dataContext, Mapper`1 mapper, Expression expression, Object[] ps, Object[] preambles)
         at LinqToDB.Linq.QueryRunner.<>c__DisplayClass26_0`1.<SetRunQuery>b__0(IDataContext db, Expression expr, Object[] ps, Object[] preambles)
         at LinqToDB.Linq.ExpressionQuery`1.System.Linq.IQueryProvider.Execute[TResult](Expression expression)
         at System.Linq.Queryable.Any[TSource](IQueryable`1 source, Expression`1 predicate)
         at Nop.Data.Migrations.UpgradeTo440.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.MigrateUp(Int64 targetVersion, Boolean useAutomaticTransactionManagement)
         at FluentMigrator.Runner.MigrationRunner.MigrateUp(Int64 targetVersion)
         at Nop.Data.Migrations.MigrationManager.ApplyUpMigrations(Assembly assembly, Boolean isUpdateProcess)
         at Nop.Web.Framework.Infrastructure.Extensions.ApplicationBuilderExtensions.StartEngine(IApplicationBuilder application)
         at Nop.Web.Startup.Configure(IApplicationBuilder application)
         at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
         at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
         at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
         at Microsoft.AspNetCore.Hosting.ConfigureBuilder.<>c__DisplayClass4_0.<Build>b__0(IApplicationBuilder builder)
         at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass15_0.<UseStartup>b__1(IApplicationBuilder app)
         at Microsoft.AspNetCore.Mvc.Filters.MiddlewareFilterBuilderStartupFilter.<>c__DisplayClass0_0.<Configure>g__MiddlewareFilterBuilder|0(IApplicationBuilder builder)
         at Microsoft.AspNetCore.Server.IIS.Core.IISServerSetupFilter.<>c__DisplayClass2_0.<Configure>b__0(IApplicationBuilder app)
         at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
         at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
      ClientConnectionId:686ffbf1-3a3e-4011-b36d-2e797bbc8d2a
      Error Number:156,State:1,Class:15
Unhandled exception. System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near the keyword 'EXISTS'.
Incorrect syntax near ','.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
   at System.Data.SqlClient.SqlDataReader.get_MetaData()
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite, String method)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
   at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
   at LinqToDB.Data.DataConnection.ExecuteReader(IDbCommand command, CommandBehavior commandBehavior)
   at LinqToDB.Data.DataConnection.ExecuteReader(CommandBehavior commandBehavior)
   at LinqToDB.Data.DataConnection.ExecuteReader()
   at LinqToDB.Data.DataConnection.QueryRunner.ExecuteReader()
   at LinqToDB.DataContext.QueryRunner.ExecuteReader()
   at LinqToDB.Linq.QueryRunner.ExecuteElement[T](Query query, IDataContext dataContext, Mapper`1 mapper, Expression expression, Object[] ps, Object[] preambles)
   at LinqToDB.Linq.QueryRunner.<>c__DisplayClass26_0`1.<SetRunQuery>b__0(IDataContext db, Expression expr, Object[] ps, Object[] preambles)
   at LinqToDB.Linq.ExpressionQuery`1.System.Linq.IQueryProvider.Execute[TResult](Expression expression)
   at System.Linq.Queryable.Any[TSource](IQueryable`1 source, Expression`1 predicate)
   at Nop.Data.Migrations.UpgradeTo440.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.MigrateUp(Int64 targetVersion, Boolean useAutomaticTransactionManagement)
   at FluentMigrator.Runner.MigrationRunner.MigrateUp(Int64 targetVersion)
   at Nop.Data.Migrations.MigrationManager.ApplyUpMigrations(Assembly assembly, Boolean isUpdateProcess)
   at Nop.Web.Framework.Infrastructure.Extensions.ApplicationBuilderExtensions.StartEngine(IApplicationBuilder application)
   at Nop.Web.Startup.Configure(IApplicationBuilder application)
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
   at Microsoft.AspNetCore.Hosting.ConfigureBuilder.<>c__DisplayClass4_0.<Build>b__0(IApplicationBuilder builder)
   at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass15_0.<UseStartup>b__1(IApplicationBuilder app)
   at Microsoft.AspNetCore.Mvc.Filters.MiddlewareFilterBuilderStartupFilter.<>c__DisplayClass0_0.<Configure>g__MiddlewareFilterBuilder|0(IApplicationBuilder builder)
   at Microsoft.AspNetCore.Server.IIS.Core.IISServerSetupFilter.<>c__DisplayClass2_0.<Configure>b__0(IApplicationBuilder app)
   at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
   at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
   at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
   at Nop.Web.Program.Main(String[] args)
   at Nop.Web.Program.<Main>(String[] args)
ClientConnectionId:686ffbf1-3a3e-4011-b36d-2e797bbc8d2a
Error Number:156,State:1,Class:15


Any idea why, please?

Thank you!
Il y a 2 ans
I've not seen this before, but are you using the DataProtectionKeys from your 4.30 install, or from 4.40.3 (App_Data > DataProtectionKeys)?

If you're using your original 4.30 ones, open them in a text editor (e.g. notepad) and change the following:

<descriptor deserializerType="Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel.AuthenticatedEncryptorDescriptorDeserializer, Microsoft.AspNetCore.DataProtection, Version=3.1.14.0, Culture=neutral, PublicKeyToken=adb9793829ddae60">


To:

<descriptor deserializerType="Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel.AuthenticatedEncryptorDescriptorDeserializer, Microsoft.AspNetCore.DataProtection, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60">


Also, are you storing the keys on the server or azure?
Il y a 2 ans
Hi,

It was OK into App_Data > DataProtectionKeys + no Azure.

The issue came from my old Sql Server 2008 instance: it was working for v.4.30, but not for 4.40.X.
It's OK now after I upgraded to Sql Server 2016.

Subject closed :)

Thanks a lot for your help!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.