You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This add the entity as added but recursively all the related entites are added as added too.
dbContext.Attached(myEntity);
This add the entity as unchanged, so I have to chaged its status to add. All related entities are added as unchenged.
dbContex.MyType.Add(myEntity);
Add all the entities as added status.
dbContext.Update(myEntity) add my entity as modified, but I need to add as added.
So I don't know if it is possible to add one entity as added and rescursive all the reset as unchanged.
The entity that I am trying to add is a realtion entity:
MyEntity
{
long IDTableA;
long IDTableB;
}
IDTableA and IDTableB are not 0, so update adds it as modified. But I know that it doesn't exists (it is not a multiuser application so only one user uses the database) so I wanted to add it as added entity. Perhaps it would be posssible to add an entity with IDs as added because I know that It doens't exist and add the related entities as unchanged.
Thanks.
The text was updated successfully, but these errors were encountered:
@ComptonAlvaro If you are using generated keys and the new entity does not have a key value set, then Attach should work in EF Core 2.0. In other cases, or when using EF Core 1.1, use TrackGraph.
i am trying to add an entity as added state but I want that all the related entites are added recursivelly as unchanged.
I have tried:
dbContext.Entry(myEntity).State = EntityState.Added;
This add the entity as added but recursively all the related entites are added as added too.
dbContext.Attached(myEntity);
This add the entity as unchanged, so I have to chaged its status to add. All related entities are added as unchenged.
dbContex.MyType.Add(myEntity);
Add all the entities as added status.
dbContext.Update(myEntity) add my entity as modified, but I need to add as added.
So I don't know if it is possible to add one entity as added and rescursive all the reset as unchanged.
The entity that I am trying to add is a realtion entity:
MyEntity
{
long IDTableA;
long IDTableB;
}
IDTableA and IDTableB are not 0, so update adds it as modified. But I know that it doesn't exists (it is not a multiuser application so only one user uses the database) so I wanted to add it as added entity. Perhaps it would be posssible to add an entity with IDs as added because I know that It doens't exist and add the related entities as unchanged.
Thanks.
The text was updated successfully, but these errors were encountered: