Composite DB keys with Entity Framework 4.0

前端 未结 2 701
-上瘾入骨i
-上瘾入骨i 2021-01-11 12:40

The re-design for a large database at our company makes extensive use of composite primary keys on the database.

Forgetting performance impacts, will this cause any

2条回答
  •  甜味超标
    2021-01-11 13:26

    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!

提交回复
热议问题