Entity Framework - Add Navigation Property Manually

不打扰是莪最后的温柔 提交于 2019-11-26 21:23:41
RPM1984

Yup - it's not that straightforward.

Here's what you do:

1 - Right click on the designer, Add -> Association

2 - Setup the association and cardinalities (People *..1 Gender, People *..1 Race)

3 - Go into the Model Browser -> Associations

4 - Right click on your newly created associations, click Properties

5 - Here you need to setup the endpoints for the key and cascade options. Make sure you get the endpoints correct. You can also setup a referential constraint here for your implicit navigational property.

6 - Map the navigational property to the relevant tables/fields.

7 - Validate your model, cross your fingers.

Hope this helps.

I came across this blog post which proposes the following solution, which worked great for me (unfortunately I could not get RPM1984's to work in my situation).

  1. Add an Association via designer background right click contextual menu
  2. Set up your Association (be sure to uncheck creation of foreign key)
  3. Right click on the association and choose Properties
  4. Click on the ... button for Referential Constraint
  5. Set up the relation between the keys within
  6. Verify (from the designer contextual menu)
  7. ???
  8. Profit!
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!