.net error while using psucli

Product: PowerShell Universal
Version: 5.3.3

Hello everyone!

We’re trying to migrate our PSU-SQLite3 database to a Microsoft SQL-Server database with help of command psu (psu Command Line Tool | PowerShell Universal).

However, if we try to use the command, we get an .net error and it seems, psu has some kind of problem to read the SQLIte-database.

Our command looks like this:

.\psu db migrate --source-connection-string 'Data Source=C:\ProgramData\UniversalAutomation\databased.db;Version=3' --target-connection-string 'Data Source=sqlserver.contoso.com;Initial Catalog=PSU;Integrated Security=True;TrustServerCertificate=true' --target-database-type 'SQL'

We get this error:

Unhandled exception. System.ArgumentException: An item with the same key has already been added. Key: -scn
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at System.CommandLine.Parsing.StringExtensions.ValidTokens(Command command)
   at System.CommandLine.Parsing.StringExtensions.Tokenize(IReadOnlyList`1 args, CommandLineConfiguration configuration, Boolean inferRootCommand)
   at System.CommandLine.Parsing.Parser.Parse(IReadOnlyList`1 arguments, String rawInput)
   at System.CommandLine.Parsing.ParserExtensions.InvokeAsync(Parser parser, String[] args, IConsole console)
   at PSUCLI.Program.Main(String[] args) in C:\actions-runner\_work\universal\universal\src\Universal.CommandLine\Program.cs:line 66
   at PSUCLI.Program.<Main>(String[] args)

What are we doing wrong?

Thank you for every hint :slight_smile:

Greetings, Ronny

Can you download the ZIP for 5.4.4 and see if the problem exists there as well?

I’ll give it a try until next week will update this post

We updates out development server and after a second try we got this error message:

PS C:\Program Files (x86)\Universal> .\psu db migrate --source-connection-string 'Data Source=C:\ProgramData\UniversalAutomation\databased.db' --target-connection-string 'Data Source=sql.contoso.com;Initial Catalog=PSH_Test;Integrated Security=True;TrustServerCertificate=true' --target-database-type 'SQL'
info: PSUCLI.DataMigrator[0]
      [00:00:00] Moving identities.
Unhandled exception: Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 1: 'no such table: Identity'.
   at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
   at Microsoft.Data.Sqlite.SqliteCommand.PrepareAndEnumerateStatements()+MoveNext()
   at Microsoft.Data.Sqlite.SqliteCommand.GetStatements()+MoveNext()
   at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReader(RelationalCommandParameterObject parameterObject)
   at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.Enumerator.InitializeReader(Enumerator enumerator)
   at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.Enumerator.<>c.<MoveNext>b__21_0(DbContext _, Enumerator enumerator)

   at Microsoft.EntityFrameworkCore.Storage.NonRetryingExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)
   at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.Enumerator.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at PSUCLI.DataMigrator.Transfer(PSUDataContext source, PSUDataContext target) in D:\a\universal\universal\src\PowerShellUniversal.CommandLine\DataMigrator.cs:line 16
   at PSUCLI.MigrateDatabaseHandler.HandleAsync(MigrateDatabaseOptions options, CancellationToken cancellationToken) in D:\a\universal\universal\src\PowerShellUniversal.CommandLine\DatabaseCommand.cs:line 103
   at System.CommandLine.Command`2.HandleOptions(TOptions options, IServiceProvider serviceProvider, CancellationToken cancellationToken) in D:\a\universal\universal\src\PowerShellUniversal.CommandLine\Command.cs:line 29
   at System.CommandLine.NamingConventionBinder.CommandHandler.GetExitCodeAsync(Object returnValue, InvocationContext context)
   at System.CommandLine.NamingConventionBinder.ModelBindingCommandHandler.InvokeAsync(InvocationContext context)
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass17_0.<<UseParseErrorReporting>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at PSUCLI.DependencyInjectionMiddleware.<>c__DisplayClass1_0.<<UseDependencyInjection>b__0>d.MoveNext() in D:\a\universal\universal\src\PowerShellUniversal.CommandLine\DependencyInjectionMiddleware.cs:line 44
--- End of stack trace from previous location ---
   at PSUCLI.DependencyInjectionMiddleware.<>c__DisplayClass1_0.<<UseDependencyInjection>b__0>d.MoveNext() in D:\a\universal\universal\src\PowerShellUniversal.CommandLine\DependencyInjectionMiddleware.cs:line 44
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass12_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<<UseVersionOption>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass19_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__18_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<<UseParseDirective>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__5_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass8_0.<<UseExceptionHandler>b__0>d.MoveNext()

For the case you need to look further into, we could provide you with our SQLliteDB-File and another information via mail.

Important info:
Actually, we try to migrate the sqllitedb-file of our development server. After this worked, our next step is to migrate our production server into a new sql database.

Greetings, Ronny

@rldml Can you email support? I’m wondering if I can get a hold of this DB and attempt this myself. The identity table should definitely exist in the source DB.