none
Change State to a Context in EF!! RRS feed

  • Question

  • hello:

    i have this code:

                    GirosRepository  g = new GirosRepository ();
                    InventariosEntities cnt = new InventariosEntities();
                    GirosMove gmove = new GirosMove();
                    ModeloEntidad.Giro giro = new ModeloEntidad.Giro();
    
                    giro.Descripcion = "nuevogiro";
                    giro.Activo = true;
                    giro.CodigoGiro = 6;
                    gmove.Add(giro);
    
                    cnt.Attach(giro);
                    cnt.ObjectStateManager.ChangeObjectState(giro, EntityState.Added);
                    cnt.SaveChanges();

    basically, im trying to change the state to the context, but it throws me an exception:

    Multiple instances of IEntityChangeTracker can not refer to an entity object.

    somebody help me!!!!!

    • Moved by CoolDadTx Monday, April 15, 2013 4:47 PM EF related
    Sunday, April 14, 2013 9:06 PM

Answers