【发布时间】:2018-04-14 23:55:26
【问题描述】:
我是 EF Core 的新手。我有两个表,这两个表几乎类似于以下两个表,如下所示:
public class Post
{
public int PostId { get; set; }
public string Title { get; set; }
public string Content { get; set; }
public int AuthorId { get; set; }
public User Author { get; set; }
public int ContributorId { get; set; }
public User Contributor { get; set; }
}
public class User
{
public string Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
[InverseProperty("Author")]
public List<Post> AuthoredPosts { get; set; }
[InverseProperty("Contributor")]
public List<Post> ContributedToPosts { get; set; }
}
当我运行 update-database 命令时,我收到以下错误
Introducing FOREIGN KEY constraint 'FK_Post_User_AuthorId' on table 'Post' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
谁能帮助我做错了什么以及如何以最好的方式解决这个问题?
谢谢
【问题讨论】:
-
如您所见,错误是关于
WorkflowRules表,不涉及Post和User表。 -
我只是以这些表格为例。无论如何,我已经更新了错误。
标签: visual-studio-2017 entity-framework-core asp.net-core-2.0