Kentico/xperience-by-kentico-kentico-migration-tool

KxpContext database connection-string hardcoded

Jan-Ole opened this issue · 4 comments

Brief bug description

When executing the Migration.Toolkit.CLI.exe it fails when trying to open a connection to the KxpContext database.
The connection-string for this context is not read from the appsettings.json but from a hardcoded connection-string in the KxpContext.cs file (line 241).

Repro steps

Build and execute the Migration.Toolkit.CLI.exe with the following command:

Migration.Toolkit.CLI.exe migrate --sites --custom-modules --users --settings-keys --page-types --pages --attachments --contact-management --forms --media-libraries --data-protection --countries

Expected behavior

Either tell people to setup the connection-string manually in the KxpContext.cs or read the KX13 connection-string from the appsettings.json

Test environment

  • Platform/OS: Windows 11 Pro Version: 23H2
  • Build with: Microsoft Visual Studio Enterprise 2022 (64-bit) Version 17.8.3

Additional context

CLI Error message:

02:42:24.708 fail: Microsoft.EntityFrameworkCore.Database.Connection[20004] An error occurred using the connection to database 'XK29_1_0_BP' on server '.'.
02:42:24.708 fail: Microsoft.EntityFrameworkCore.Query[10100] An exception occurred while iterating over the results of a query for context type 'Migration.Toolkit.KXP.Context.KxpContext'. System.InvalidOperationException: An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding 'EnableRetryOnFailure' to the 'UseSqlServer' call.  ---> Microsoft.Data.SqlClient.SqlException (0x80131904)

Add any other context about the problem here.

Screenshots

image

I have the same problem here, I had to comment out the code in the screenshot to get it working.

I wasn't quite sure what that context is for, so I added my connection string to the KX13 source database there and executed the CLI.

Thank you for bringing this to our attention. We will investigate and keep you informed of our progress.

@liamgold that was correct workaround to comment code
@Jan-Ole KxpContext is used to query target database. KxpContext is legacy approach and is replaced with Kentico API access. (in past KxpContext was used to do inserts/updates that couldn't be done with Kentico API).

I have removed generated hardcoded configuration in PR #197