Error while registering database using API
rmajumdar
Posts: 2
Hi,
I am trying to compare a live database and a script folder using SQLComapre 7 API. It was working for first few days, but it is suddenly failing with the following error message when I am trying to register the database that represents the scripts folder.
'An item with the same key has already been added.' at
scriptFolderDatabase.Register(parameter.InputFolderPath, dbInfo, databaseOptions)
the full code is :
Options databaseOptions = Options.Default | Options.IgnoreCollations | Options.IgnoreFileGroups | Options.IgnoreFillFactor |
Options.IgnoreWhiteSpace | Options.IgnoreQuotedIdentifiersAndAnsiNullSettings;
Database emptyDatabase = new Database();
emptyDatabase.Register(parameter.ToRedGateConnectionProperty(), databaseOptions);
Database scriptFolderDatabase = new Database();
ReadFromScriptDatabaseInformation dbInfo = new ReadFromScriptDatabaseInformation();
dbInfo.DefaultCollation = "SQL_Latin1_General_CP1_CI_AS";
dbInfo.DefaultOwner = "dbo";
scriptFolderDatabase.Register(parameter.InputFolderPath, dbInfo, databaseOptions);
the stack trace is:
at RedGate.SQLCompare.Rewriter.Analysis.Analyser`1.WaitForBackgroundThread()
at cV.a(FileInfo )
at cV.a()
at RedGate.SQLCompare.Engine.Database.Register(String path, ReadFromScriptDatabaseInformation dbinfo, Options options)
at PwC.Audition.Tools.SQLCompareWrapper.SchemaScriptGenerator.GenerateSchemaScript(SchemaScriptGeneratorParameter parameter) in \CAR_Audition\Tools\PwC.Audition.Tools.SQLCompareWrapper\SchemaScriptGenerator.cs:line 33
Can anyone please help with that?
I am trying to compare a live database and a script folder using SQLComapre 7 API. It was working for first few days, but it is suddenly failing with the following error message when I am trying to register the database that represents the scripts folder.
'An item with the same key has already been added.' at
scriptFolderDatabase.Register(parameter.InputFolderPath, dbInfo, databaseOptions)
the full code is :
Options databaseOptions = Options.Default | Options.IgnoreCollations | Options.IgnoreFileGroups | Options.IgnoreFillFactor |
Options.IgnoreWhiteSpace | Options.IgnoreQuotedIdentifiersAndAnsiNullSettings;
Database emptyDatabase = new Database();
emptyDatabase.Register(parameter.ToRedGateConnectionProperty(), databaseOptions);
Database scriptFolderDatabase = new Database();
ReadFromScriptDatabaseInformation dbInfo = new ReadFromScriptDatabaseInformation();
dbInfo.DefaultCollation = "SQL_Latin1_General_CP1_CI_AS";
dbInfo.DefaultOwner = "dbo";
scriptFolderDatabase.Register(parameter.InputFolderPath, dbInfo, databaseOptions);
the stack trace is:
at RedGate.SQLCompare.Rewriter.Analysis.Analyser`1.WaitForBackgroundThread()
at cV.a(FileInfo )
at cV.a()
at RedGate.SQLCompare.Engine.Database.Register(String path, ReadFromScriptDatabaseInformation dbinfo, Options options)
at PwC.Audition.Tools.SQLCompareWrapper.SchemaScriptGenerator.GenerateSchemaScript(SchemaScriptGeneratorParameter parameter) in \CAR_Audition\Tools\PwC.Audition.Tools.SQLCompareWrapper\SchemaScriptGenerator.cs:line 33
Can anyone please help with that?
Comments
It might be a good idea to try troubleshooting this using the SQL Compare 7 UI. It has a logging feature that should at least show which object is causing the problem; and it might also give you a better error message during comparison.
If you are happy to try the UI, you can enable logging by selecting the SQL Compare logo on the title bar, and then 'Enable Logging >> Verbose'
If this doesn't help, please can you send any logs, a snapshot of the live database, and a copy of the scripts folder to support@red-gate.com and we can try and recreate the problem here.