title: EF4 error:The relationship between the two objects cannot be defined because they are attached to different ObjectContext objects
body: <p>hi I have a question I'am using for my web site wscf in vs2010 that use de model MVP(model,view,presenter) and for my model layer (data acces layer) iam using EF</p>
  
  <p>that seguimiento's tables is an intermediate table between be cliente and gventa tables
  so I have my Insert in seguimiento's table with L2E in my (DAL LAYER)like this</p>
  
  <pre><code>public void InsertarSeguimiento(Seguimiento Seg)
      {
          using (var cont = new CelumarketingEntities())
          {
              cont.AddToSeguimiento(Seg);
              cont.SaveChanges();
          }
      }
  </code></pre>
  
  <p>and in my presentation'S layer, I capture for my web form, from textbox the field for seguimiento And I get these error when I try to put the object cliente to  (seguimiento) objProxy.ClienteReference.Value<br>
  <strong>The relationship between the two objects cannot be defined because they are attached to different ObjectContext objects.</strong>
  and I don't understand why since gventa object have no that error</p>
  
  <pre><code> protected void BtnInsertar_Click(object sender, EventArgs e)
          {
              string nombreGVentas = TbxVendedor.Text;
              char[] delimit = new char[] { ' ' };
              string[] arreglo = nombreGVentas.Split(delimit);
              GVenta IdGVentas = _presenter.getventas(arreglo[0], arreglo[1]);
  
              string nombrecliente = TbxCliente.Text;
              Project.CAD.Cliente  idCliente = _presenter.getCliente(nombrecliente);
  
              string hora = DdlHora.SelectedValue;
              string minutos = DdlMinutos.SelectedValue;
  
              string HorMin = hora + ":" + minutos;
              Project.CAD.Seguimiento objProxy = new Project.CAD.Seguimiento();
  
              objProxy.GVentaReference.Value = IdGVentas;
              objProxy.ClienteReference.Value = idCliente;   *// here i get the errors*
              objProxy.Descripccion = TbxDescripccion.Text;
              objProxy.Fecha = Calendar1.SelectedDate;
              objProxy.Hora = HorMin;
  
               _presenter.insertarseg(objProxy);   
          }
  </code></pre>