How to set up a many-to-many relationship in Entity Framework designer thingy

后端 未结 2 1230
滥情空心
滥情空心 2020-12-20 18:07

I\'m an NHibernate developer trying to give Entity Framework a shot in a hobby project. I\'m used to specifying mapping data in code using Fluent NHibernate. Pardoning Micro

相关标签:
2条回答
  • Your junction table must be what MS calls a 'pure join table' - it must contain only the two foreign keys, and no other columns. In your case, that means you must delete the primary key column.

    0 讨论(0)
  • 2020-12-20 18:42

    When you add the association to the model you choose each of your two tables and choose "many" on both sides of the relationship. When this generates the database script a join table with only the two keys will be created for you.

    enter image description here

    By the way: If you don't like using Model-first and would rather code research "Code-First" development for the Entity Framework. You can also do Database-First if you prefer that.

    0 讨论(0)
提交回复
热议问题