title: EF 4.3 Many to Many Relation and Junction Table Update
body: <pre><code>public class User
  {
      public int Id{ get; set; }
      public ICollection&lt;UserAction&gt; UserActions{ get; set; }
      public string Name{ get; set; }
  }
  
  public class Action
  {
      public int Id{ get; set; }
      public string Name{ get; set; }
      public ICollection&lt;UserAction&gt; UserActions{ get; set; }
  }
  
  public UserAction
  {
      public int Id{ get; set; }
      public User User{ get; set; }
      public Action Action{ get; set; }
      public int Type {get;set}       
  }
  </code></pre>
  
  <p>and in repository class</p>
  
  <pre><code>public void Update(User user,List&lt;UserAction&gt; actions)
  {
      User entity = this.GetUser(user.Id);           
      entity.UserActions.Clear();
      entity.UserActions= actions;
      this.siteRepository.Update&lt;SiteUser&gt;(user);
      this.siteRepository.UnitOfWork.SaveChanges();
  }
  </code></pre>
  
  <p>i am gettng a error below like </p>
  
  <p>The operation failed: The relationship could not be changed because one or more of the foreign-key properties is non-nullable. When a change is made to a relationship, the related foreign-key property is set to a null value. If the foreign-key does not support null values, a new relationship must be defined, the foreign-key property must be assigned another non-null value, or the unrelated object must be deleted.</p>