Error while calling BuildFromDifferences (key not present)

Automate and integrate using the SQL comparison API

Moderators: Chris Auckland, David Atkinson, Michelle Taylor, chengvoon.tong

Error while calling BuildFromDifferences (key not present)

Postby JacobEwald » Wed Nov 13, 2013 4:28 pm

I'm getting the following exception while calling BuildFromDifferences:
Code: Select all
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at #8rg.#wvg..ctor(Permissions permissions, Permissions targetPermissions, Options options)
   at RedGate.SQLCompare.Engine.Permissions.#Ghh(SQLScriptBuilder #wUrc, Options #5OPb, Permissions #vUrc, Boolean #yUrc, Boolean #zUrc, String #xUrc, Boolean& #AUrc)
   at RedGate.SQLCompare.Engine.Work.#gQh(Options #5OPb, SQLScriptBuilder #wUrc, #yvg #mXrc, Boolean #yUrc)
   at RedGate.SQLCompare.Engine.Work.GenerateSql(Differences differences, Difference onlyDifferenceToInclude, Options options, Boolean runOnTwo)
   at RedGate.SQLCompare.Engine.Work.BuildFromDifferences(Differences differences, Difference onlyDifferenceToInclude, Options options, Boolean runOnTwo)
   at RedGate.SQLCompare.Engine.Work.BuildFromDifferences(Differences differences, Options options, Boolean runOnTwo)


I'm using a snapshot created by the same version of the SDK to push the changes to 3 test databases. The problem only happens on 1 of the 3. The other weird thing is that I can use the exact same snapshot and push to the failing database using the SQL Compare UI and it works just fine. It seems to only be an issue with the SDK. I'm hoping someone can give me some direction on fixing this problem, thanks!
JacobEwald
 
Posts: 3
Joined: Fri Nov 08, 2013 9:21 pm

Postby Brian Donahue » Fri Nov 15, 2013 9:29 am

Hello,

Usually this sort of thing is caused by permissions. You may be using a different account when running the SDK app, so check the connection properties. If you set the ConnectionProperties to use SA and it works, that's definitely the problem.

If you need to narrow it down to a specific object, you can debug your app - when the exception breaks into the debugger, you can have a look at the locals and see if you can find the name of a SQL object (they almost always have brackets in the name).

Hope this helps.
Brian Donahue
 
Posts: 6669
Joined: Mon Aug 23, 2004 10:48 am

Postby JacobEwald » Mon Nov 18, 2013 3:03 pm

I'm using the SA account for generating and publishing the snapshot, and it fails when running through SDK, but succeeds when running through the UI.

When I debug the app and it throws the exception, I'm not sure exactly what I'm looking for in the locals. The Work object has an ExecutionBlock that looks correct, so it seems to have detected the changes without any problem, but the exception still throws.
JacobEwald
 
Posts: 3
Joined: Fri Nov 08, 2013 9:21 pm

Postby JacobEwald » Mon Nov 18, 2013 3:14 pm

Found it!

It was one of 2 changes I made. There was a role that needed to own a schema, and a user needed to be added to that role. I did those two things manually though SQL Management Studio. The next time I ran the SDK app it succeeded without throwing that exception.

I would hope that this exception would be handled in a future version, but for now I'll know how to fix it if it comes up again.
JacobEwald
 
Posts: 3
Joined: Fri Nov 08, 2013 9:21 pm

Postby Brian Donahue » Mon Nov 18, 2013 4:45 pm

It would be better if this code was more graceful, but in the meantime, insufficient permissions will result in unhelpful error messages that would require some code debugging.
Brian Donahue
 
Posts: 6669
Joined: Mon Aug 23, 2004 10:48 am


Return to SQL Comparison SDK 10

Who is online

Users browsing this forum: No registered users and 0 guests