Entity Framework, code-first: combining master-detail with zero-to-one relationship
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a simple master-detail relationship using code first EF: public class User { public string Id { get; set; } public ICollection<Tasks> Tasks { get; set; } } public class Task { public string Id { get; set; } [Required] public string UserId { get; set; } public User User { get; set; } } Now I want to modify it so that users can have a single, most important task. So I modify the User class to add it: public class User { public string Id { get; set; } public ICollection<Tasks> Tasks { get; set; } public string MostImportantTaskId { get;