Red Gate forums :: View topic - KeyNotFoundException in BuildFromDifferences
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SQL Comparison SDK Previous Versions
SQL Comparison SDK Previous Versions forum

KeyNotFoundException in BuildFromDifferences

Search in SQL Comparison SDK Previous Versions forum
Post new topic   Reply to topic
Jump to:  
Author Message
doa



Joined: 16 Sep 2009
Posts: 4

PostPosted: Wed Sep 16, 2009 8:44 am    Post subject: KeyNotFoundException in BuildFromDifferences Reply with quote

Hi

I use SDK 8 to generate a change script between two databases.

Code:

Database sourceDB = new Database();
Database destinationDB = new Database();
           
sourceDB.Register(new ConnectionProperties(sServer, sDB, sUser, sPass), Options.Default);
destinationDB.Register(new ConnectionProperties(dServer, dDB, dUser, dPass), Options.Default);

Differences differences = sourceDB.CompareWith(destinationDB, Options.Default);

foreach (Difference difference in differences)
    difference.Selected = true;

Work work = new Work();

work.BuildFromDifferences(differences, Options.Default, true);


I got a KeyNotFoundException from BuildFromDifferences.
"The given key was not present in the dictionary."

The difference collection contains several elements and seems OK

Stacktrace:
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at S..ctor(Permissions permissions, Permissions targetPermissions, Options options)
at RedGate.SQLCompare.Engine.Permissions.a(IBlockWriter , Options , Permissions , Boolean , Boolean , String , Boolean& )
at RedGate.SQLCompare.Engine.Work.a(Options , IBlockWriter , U , Boolean )
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)
at GenerateDiffScript(String connectionString) in file

FileVersion info:
RedGate.SQLCompare.Engine.dll - 8.1.0.148

I cannot see that I'm doing something wrong? Is there a bug in SQL Comparison SDK 8?
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6643

PostPosted: Thu Sep 17, 2009 4:04 pm    Post subject: Reply with quote

Can you please run the following query? There are some new SQL Server 2008 permissions that aren't supported by SQL Compare. One of them is the "view change tracking" permission.
Code:
SELECT CAST(0 AS INT) AS ColumnPermissionID, sp.grantee_principal_id as uid, su.name AS UserName,
OBJECT_NAME(sp.major_id) AS ObjectName,
SCHEMA_NAME(so.schema_id) AS ObjectOwner,
1 AS class, sp.type, sp.state,
so.type AS ObjectType,
CONVERT(int, null) as columns
FROM sys.database_permissions AS sp WITH (NOLOCK) INNER JOIN sys.sysusers su WITH (NOLOCK) ON su.uid=sp.grantee_principal_id INNER JOIN sys.objects so WITH (NOLOCK) ON so.object_id=sp.major_id WHERE sp.major_id>0 AND sp.class = 1 AND sp.minor_id = 0 AND (sp.type in ('IN','DL','EX') OR CHARINDEX(sp.type, 'CRFNCRTBCRDBCRVWCRPRBADBCRDFBALOCRRU')%4 > 0) AND so.schema_id IS NOT NULL AND sp.type='VWCT'
GROUP BY sp.major_id, sp.grantee_principal_id, sp.grantor_principal_id, sp.type, sp.state, so.type, su.name, so.schema_id
This query will return rows when objects in your database use this right.
Back to top
View user's profile Send private message
doa



Joined: 16 Sep 2009
Posts: 4

PostPosted: Thu Sep 17, 2009 8:51 pm    Post subject: Reply with quote

The query doesn't return any rows. We are using change tracking on the database and most tables. If I use the SQL Compare UI program it works and I can generate the script I want. I only get this excepion when I use the SDK.
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6643

PostPosted: Fri Sep 18, 2009 9:26 am    Post subject: Reply with quote

Can you try referencing the DLLs from the SQL Compare (UI) installation folder? Possibly you are encountering a bug that has been fixed in SQL Compare 8.1. Updating the SQLCompare.Engine references should get your program to behave in the same way as SQL Compare.
Back to top
View user's profile Send private message
doa



Joined: 16 Sep 2009
Posts: 4

PostPosted: Fri Sep 18, 2009 1:55 pm    Post subject: Reply with quote

Hi

I'm already refering RedGate.SQLCompare.Engine.dll version 8.1.0.148

MSSQL 2008 was released over one year ago. Are you saying that i am the first one trying make a change script on SQL server 2008 with "view change tracking permission" with SDK 8.1?
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6643

PostPosted: Fri Sep 18, 2009 2:06 pm    Post subject: Reply with quote

No, this is not the first time this has come up, which is exactly why I'd asked. SQL Compare 7.2 and up are supposed to support SQL Server 2008, I have just seen that one or two permission types have been left out by accident.
Back to top
View user's profile Send private message
doa



Joined: 16 Sep 2009
Posts: 4

PostPosted: Mon Sep 21, 2009 7:03 am    Post subject: Reply with quote

When do you have a new version that will support "view change tracking" permission.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group