开发者

Creating Composite primary keys in a many-to-many relationship in Entity Framework

I have two tables th开发者_Go百科at are connected via a join table in a many-to-many relationship in the Entity Framework. I need to add a composite primary key in the join table for the two columns that are related to the joined tables via standard foreign keys but I'm sure how to do that.


If your join table has a composite key on both foreign keys, the Entity Framework designer in VS2008/2010 should pick up on that.

SQL:

CREATE TABLE MyTable
(
  ColumnFK1  int,
  ColumnFK2  int

PRIMARY KEY (ColumnFK1, ColumnFK2)
)

If the table is already created you can modify the primary key in Management Studio.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜