views:

91

answers:

1

I'm getting more and more frustrated with EF...

I have a table called ExtendedField with:

Record
DocRef DocType
Name

Record is the primary key
DocRef and DocType are foreign keys used to identify which Ticket they belong to
Name is the key used by the "definition" table to define what the field actually is

So basically I need 2 associations:

One between Ticket and ExtendedField on ExtendedField.DocRef=ticket.record and ExtendedField.docType=HeaderDocType

One between Definition on ExtendedField.Name=Definition.FieldName

Then I still need Record to be the primary key so I can directly access the fields.

As near as I can tell this is impossible to do in Entity Framework. For every association all the keys need to be mapped together, whereas I need two keys for one association, 1 key for another one and the actual primary key wouldn't be used in any associations.

It doesn't appear that you can define an association between fields that aren't entity keys either.

So is there any way to do this? Am I missing something?

A: 

It's a v1, bro. I myself have had some major pain with mapping of key constraints in EF. I hear that better things are coming in v2.

Jeremy Sullivan
Any chance v2 is coming out in the next couple days? If not I might have to go back to Linq2Sql given I need to finish this in the next two weeks. :(
Telos
From my experience, I would just go back to Linq To SQL for now. It's a great technology that has been overlooked in the current EF buzz... not to mention that it way easier to use and more useful at this point (in my opinion). For instance, I can't use a Stored Procedure that doesn't return a value or return a scalar value. I have to return one of the EF objects. I just don't think that it's ready for production. There has been rumor of EF v2 coming out with .Net 4.0. Good luck and happy coding! :)
Jeremy Sullivan

related questions