Composite DB keys with Entity Framework 4.0

前端 未结 2 682
-上瘾入骨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:20

    No, EF4 supports composite keys just fine.

    The problem is a table with a surrogate key and composite keys. You can only set a 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.

提交回复
热议问题