Base solution for your next web application
Open Closed

MultiTenancy Tenant Entity update error #1169


User avatar
0
marcl created

Hi,

I want to upate entity object, but I got this error.

Steps:

  1. document = await _re.GetAsync(id.Value);
  2. document.FullPath = filePath;
  3. await _re.UpdateAsync(document); Now get an error: Attaching an entity of type 'eDocument.MultiTenancy.Tenant' failed because another entity of the same type already has the same primary key value. This can happen when using the 'Attach' method or setting the state of an entity to 'Unchanged' or 'Modified' if any entities in the graph have conflicting key values. This may be because some entities are new and have not yet received database-generated key values. In this case use the 'Add' method or the 'Added' entity state to track the graph and then set the state of non-new entities to 'Unchanged' or 'Modified' as appropriate.

My document class: public class Document : Entity<int>, IFullAudited, IMayHaveTenant

I continuously get this error after I update abp framework. But, got this error if I save document after page is loaded. The second document save is working.

Any help is appreciated

Marcell


5 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Where do you run these lines ? In an application service ? Can you share your method definition including these lines ?

  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    Also, is it working if you don't call _re.UpdateAsync ?

  • User Avatar
    0
    marcl created

    <cite>ismcagdas: </cite> Hi,

    Where do you run these lines ? In an application service ? Can you share your method definition including these lines ?

    Hi,

    I use update code in controller in Web layer.

    thx Marcell

  • User Avatar
    0
    marcl created

    <cite>hikalkan: </cite> Hi,

    Also, is it working if you don't call _re.UpdateAsync ?

    Hi,

    I'll try it.

    thx Marcell

  • User Avatar
    0
    marcl created

    <cite>marcl: </cite>

    <cite>hikalkan: </cite> Hi,

    Also, is it working if you don't call _re.UpdateAsync ?

    Hi,

    I'll try it.

    thx Marcell

    Hi,

    No, I tried it.

    thx

    Marcell