Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3310322
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:44:47+00:00 2026-05-17T21:44:47+00:00

hi I have a question I’am using for my web site wscf in vs2010

  • 0

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

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

public void InsertarSeguimiento(Seguimiento Seg)
    {
        using (var cont = new CelumarketingEntities())
        {
            cont.AddToSeguimiento(Seg);
            cont.SaveChanges();
        }
    }

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
The relationship between the two objects cannot be defined because they are attached to different ObjectContext objects.
and I don’t understand why since gventa object have no that error

 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);   
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T21:44:47+00:00Added an answer on May 17, 2026 at 9:44 pm

    Problem is that your idCliente is already attached to the context here:

    Project.CAD.Cliente  idCliente = _presenter.getCliente(nombrecliente);
    

    So, when you try to assign it to the other object that’s also in some other context (the line where you get the error), the EF throws error since it don’t know what object to put in what context (it can belong to only one context).

    What you need to do is to detach idCliente from it’s context before returning in _presenter.getCliente() method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have question about NSView: Imagine a Custom View where the mouseDown, mouseDrag and
I have a question about using streams in .NET to load files from disk.
I have a question about copy constructors/copying objects. I have a class that has
I have a question about the basic wav file data chunk. I know that
We have the question is there a performance difference between i++ and ++i in
We have a question with regards to XML-sig and need detail about the optional
I have a Question class: class Question { public int QuestionNumber { get; set;
I have a question on the best way of exposing an asynchronous remote interface.
I have a question about best practices regarding how one should approach storing complex
I have a question regarding the two additional columns (timeCreated, timeLastUpdated) for each record

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.