EF5 one-to-one without navigation

后端 未结 2 568
遥遥无期
遥遥无期 2021-01-26 16:35

I\'m trying to do a one-to-one relationship, with the navigation property just on one side (MVC4, EF5, code first).

public class User {

  public int UserId { ge         


        
2条回答
  •  故里飘歌
    2021-01-26 17:01

    1:1 code first in EF requires the dependent table to have the SAME primary key. Otherwise what you want to do will work.

    EDIT Similar SO post Code First and Fluent API one to one relationship

    Here is the MS EF site sample. http://msdn.microsoft.com/en-us/data/jj591620#RequiredToRequired

提交回复
热议问题