views:

52

answers:

1

When I try to use these two features together, I get a compilation error on my model (note, I've renamed the entity for my _CT table "ContentHistory" and my SL4 Unit Test project is called "DomainServices.UnitTest":

Error 39 Property 'DomainServices.Web.ContentHistory.C___seqval' is marked as a key
property and is of Type 'System.Byte[]', which is not a supported type for a key member.
DomainServices.UnitTests

Has anyone here gotten CDC and EF4 to play nicely together?

A: 

Okay, here's what I've done to work around this issue. I made sure that every table that I want to enable CDC on has a LastModified column of type datetime. Then, I added a key (from an EF point of view) consisting of the LastModified column and the __$operation column. I figure this is "probably unique" (which is somewhat frightening, but probably okay). My reasoning is that the LastModified is accurate to about 3ms, so the only time that I'll (realistically) get 2 rows in my CDC table with the same LastModified is on an update; but, on an update those two rows will have different __$operation values (a 3 and a 4). So, compounding those together makes at least a modicum of sense for a key. I am not a big fan of this, and wish that EF4 would support tables with no keys. If anyone has a suggestion, please please let me know.

David Moye
To reiterate, I don't like this answer. It's just what I'm doing to "get by." If there's a better answer out there, someone please chime in :)
David Moye