Cannot save entity because it is not tracked by the context.

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
-marcelo-
Posts: 17
Joined: Wed 28 Jun 2017 12:35

Cannot save entity because it is not tracked by the context.

Post by -marcelo- » Tue 08 Aug 2017 21:28

Devart´s newbie here...
I made a partial class to complement the DataContext as generated by Entity developer (5.7.586) so I
can implement the partials Insert/Update/Delete, this way

Code: Select all

        partial void InsertSomeEntity(SomeEntity instance)
        {
            ExecuteDynamicInsert(instance);
        }

        public void InsertSomeEntity(SomeEntity instance, bool dummy )
        {
            InsertSomeEntity(instance);
        }
The last is to change the signature, so it can be public. But when I call this method with a new instance of SomeEntity, the library throws an exception saying "Cannot save the entity object 'SomeEntity' because it is not tracked by the context."

If the partial methods are there (in the code generated) as well as a collection of them ( public Devart.Data.Linq.Table<SomeEntity> SomeEntities) how is this that the entity is not tracked?
What am I doing the wrong way?
TIA

-marcelo-
Posts: 17
Joined: Wed 28 Jun 2017 12:35

Re: Cannot save entity because it is not tracked by the context.

Post by -marcelo- » Wed 09 Aug 2017 13:51

I found my error: for insertion of a new entity I must go throug context.SomeEntities.InsertOnUpdate( instance ) and context.SubmitChanges();

Shalex
Site Admin
Posts: 8247
Joined: Thu 14 Aug 2008 12:44

Re: Cannot save entity because it is not tracked by the context.

Post by Shalex » Thu 10 Aug 2017 15:10

Thank you for confirming solution. As we understood, no investigation on our side is required.

Post Reply