我通读了我能找到的其他答案,但没有一个对我有帮助。我对 .NET、Entity、C# 等还是很陌生。所以我希望你能原谅我。我正在尝试创建一个“种子”文件,当我尝试单独为所有表播种时,当它是一个相关表时,我得到了错误。我不仅要查看子表,还要查看孙子表(希望这是有道理的)。例如,由于我发现了一个帖子,这就是我现在正在尝试的:
context.Projects.AddOrUpdate(i => i.ProjectID, 
     new Project
     {
        ProjectID = 1,
        Title = "Project 1",
        ProjectDoc = new List<ProjectDoc>
            {
                new ProjectDoc { 
                     ProjectDocID = 1, ProjectID = 1, Content = "Doc Content", DocTitle = "Chapter 1", 
                        Comment = new List<Comment> 
                        {
                             new Comment { ProjectDocID = 1, CommentID = 1, Text = "Comment text" }
                        }
                     }
                  }
             }
        );
我的问题是:
 Comment = **new** List<Comment> 
该“新”导致错误:无法隐式转换类型'System.Collections.Generic.List ....
我试图用谷歌搜索,但我不明白我发现的行话。帮助?