Composite DB keys with Entity Framework 4.0?

No, EF4 supports composite keys just fine The problem is a table with a surrogate key and composite keys. You can only set an single key on each model; that key can have multiple fields, but you can only have one from the designer standpoint. Not sure about manually editing xml or code only mapping You can set a field as an Identity and not a key if you need a composite and surrogate key on the same table.

The Identity ( Id ) field won't be used by the ObjectContext or ObjectStateTracker but will increment and be queryable just fine though.

No, EF4 supports composite keys just fine. The problem is a table with a surrogate key and composite keys. You can only set an single key on each model; that key can have multiple fields, but you can only have one from the designer standpoint.

Not sure about manually editing xml or code only mapping. You can set a field as an Identity and not a key if you need a composite and surrogate key on the same table. The Identity ( Id ) field won't be used by the ObjectContext or ObjectStateTracker but will increment and be queryable just fine though.

I have had problems with EF4 and composite keys. It doesn't support columns being used as components in more than one key in a join table. See my previous question Mapping composite foreign keys in a many-many relationship in Entity Framework for more details.

The nuts of it is that when you have a join table (describing a many-many relationship) where both of the relationships use a common key, you'll get an error like Error 3021: Problem in mapping fragments...: Each of the following columns in table PageView is mapped to multiple conceptual side properties: PageView. Version is mapped to (PageView_Association.View. Version, PageView_Association.Page.

Version) The only way around it was to duplicate the column which defeats the purpose of having it there at all. Good luck!

1 Ridiculously annoying. – Jeremy Holovacs Sep 25 at 17:04.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions