Moving from LiteDB to SQL

It seems like some sort of data condition is causing this issue. We’ll put a workaround in place in the DataMigrator. It will be released in 3.7.7.

Thanks @adam ill keep an eye out.

@adam

Close but no cigar

One thing I would recommend doing is running it with --ContinueOnError. You may have some errors due to LiteDB not being relational but at least we can find out how far off the migration is.

–ContinueOnError seemed to work. Thanks adam!

Migrated our PSU db to Sql and all was well.

Configured the appsettings to point to the new db with the following settings

{
  "Kestrel": {
    "Endpoints": {
      "HTTP": {
        "Url": "http://*:5000"
      }
    }
  },
  "Plugins": [
    "SQL"
  ],
  "Data": {
    "RepositoryPath": "%ProgramData%\\UniversalAutomation\\Repository",
    "ConnectionString": "Data Source=sql.windows.net; User ID=User; Password=; Initial Catalog=PSU;TrustServerCertificate=True;Integrated Security=true"
  }
}

Application: Universal.Server.exe
CoreCLR Version: 6.0.1322.58009
.NET Version: 6.0.13
Description: The process was terminated due to an unhandled exception.
Exception Info: Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid object name 'HangFire.Hash'.
Invalid object name 'HangFire.Set'.
   at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at Microsoft.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
   at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean isAsync, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
   at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry, String method)
   at Microsoft.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry, String methodName)
   at Microsoft.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at Microsoft.Data.SqlClient.SqlCommandSet.ExecuteNonQuery()
   at Hangfire.SqlServer.SqlCommandBatch.ExecuteNonQuery()

Any idea? @adam

I think i figured it out… This is the connection I am using.

{
  "Kestrel": {
    "Endpoints": {
      "HTTP": {
        "Url": "http://*:5000"
      }
    }
  },
  "Authentication": {
    "Windows": {
      "Enabled": "true"
    }
  },
  "Plugins": [
    "SQL"
  ],
  "Data": {
    "RepositoryPath": "%ProgramData%\\UniversalAutomation\\Repository",
    "ConnectionString": "Data Source=sql.database.windows.net;Database=PSU;User ID=user;Password=password;Trusted_Connection=False;Encrypt=True;"
  }
1 Like