mostlylucid

scott galloway's personal blog...
posts - 916, comments - 758, trackbacks - 11

My Links

News

Archives

Post Categories

Misc. Coding

The EF Fail Whale strikes again…

UPDATE: Thanks for all those who commented on this. Turns out the problem was pretty simple. You just have to get rid og the ‘FileId’ and ‘DirectoryId’ properties. They’re ONLY for navigation so cannot be in the entity as fields too…easy peasy :)

 

I like EF, conceptually and in practice it’s pretty nice. EF4 adds a lot of the missing goodness. There’s one thing which ALWAYS stumps me in EF 3 though…this VERY simple paradigm…

Given this class layout (generated from a SQLLite DB)

 

image

See the little 0..1->* relationship? Should be dead simple, the DirectoryId in the UploadFile entity maps to the WatchDirectory Entity…with this association:

 

image

I ask you, how the hell can that fail??? But no matter what, this happens…

 

Error    3    Error 3007: Problem in Mapping Fragments starting at lines 124, 154: Non-Primary-Key column(s) [DirectoryId] are being mapped in both fragments to different conceptual side properties - data inconsistency is possible because the corresponding conceptual side properties can be independently modified.
    G:\Work\cozwecan_code\UploadClient\cozwecan.pix.client\cozwecan.pix.client\Model.edmx    155    11    cozwecan.pix.client

 

Anyone got more of a clue about EF than I have???

Print | posted on Thursday, January 07, 2010 8:04 AM |

Feedback

Gravatar

# re: The EF Fail Whale strikes again…

Considering it has been a month you either have already fixed this problem or no longer care, but the answer is that DirectoryID needs to be deleted from UploadFile. It is a foreign key and EF3 hides foreign keys inside the association. EF4 doesn't.
2/2/2010 3:17 PM | Colin Blair
Gravatar

# re: The EF Fail Whale strikes again…

Well, this is a little late in coming, but did you ever sort this out? This error message has definitely caused me to lose some hair, but I think I finally get it. The problem is that the relationship between "UploadFile" and "WatchDirectory" wants complete control over UploadFile.DirectoryId. By mapping UploadFile.DirectoryId as part of the relationship and also as a scalar property, you are introducing the possibility that the property and the relationship could be set to inconsistent values.
2/12/2010 7:44 AM | Daniel Pratt
Comments have been closed on this topic.

Powered by: