Entity framework EF核心在查询中一对一重复

Entity framework EF核心在查询中一对一重复,entity-framework,one-to-one,Entity Framework,One To One,我定义了两个类: class Post { public int? MainPictureId { get; set;} public Picture MainPicture { get; set;} } class Picture { public int PostId {get; set;} public Post Post {get; set;} } 当我执行以下操作时,每个帖子只出现一次: context.Posts.Select(p => new { p

我定义了两个类:

class Post {
  public int? MainPictureId { get; set;}
  public Picture MainPicture { get; set;}
}

class Picture {
  public int PostId {get; set;}
  public Post Post {get; set;}
}
当我执行以下操作时,每个帖子只出现一次:

context.Posts.Select(p => new {
   p.Id
}
但是如果我尝试跟随者,我会得到重复的帖子,每个帖子都有一张,但是我只想得到与帖子相关联的主图片

context.Posts.Select(p => new {
   p.Id,
   p.MainPicture,
}