Entity framework 使用实体框架更新/添加导航属性

Entity framework 使用实体框架更新/添加导航属性,entity-framework,Entity Framework,我正在实体框架6中使用存储库和工作单元模式 我的实体(模型类)具有以下关系: Article ______________ __________|__________ _______________ | | | | Tags Images References Authors Re

我正在实体框架6中使用存储库和工作单元模式

我的实体(模型类)具有以下关系:

                            Article 
     ______________ __________|__________ _______________
    |              |                     |               |
   Tags         Images     References   Authors        Reviewers
无论何时创建
文章
,数据都将插入到所有表中(即
文章
标记
图像
引用
作者
审阅者
文章
和其他子表之间存在一对多关系。
添加
方法将传递一个
文章
对象,该对象如下所示:

public class Article 
{
   public int articleId {get;set;}
   ICollection Tags {get;set;}
   Icollection Images {get;set;}
   ICollection Authors {get;set;}
   ICollection Reviewers {get;set;}
}
public void Add (Article arc)
{
  this.context.Article.Add(arc); 
}
将其添加到数据库很简单,我的操作如下:

public class Article 
{
   public int articleId {get;set;}
   ICollection Tags {get;set;}
   Icollection Images {get;set;}
   ICollection Authors {get;set;}
   ICollection Reviewers {get;set;}
}
public void Add (Article arc)
{
  this.context.Article.Add(arc); 
}
对于更新,我不知道最好的方法是什么。用户可以通过修改导航属性和/或添加更多内容来传递文章对象。 e、 g.现有审查人可以修改,也可以添加更多

我在每个导航属性中都有复合键(例如,对于
标记
its
TagId
ArticleId


请推荐一些方法

这篇文章解释了使用存储库模式的工作单元。基本阅读:为什么Entity Framework将现有对象重新插入我的数据库?如何处理缺少的外键