TrackableCollection
(context.Entities.Add(entity)
) (EntityState = New)TrackableCollection
(context.Entities.Remove(entity)
) (EntityState = Unmodified)context.SubmitChanges()
)I still get validation errors from the data annotations associated with the entity, why?
public class Entity
{
[Required]
public string Name { get; set; }
}
It is tracking the collection of removed entities, even though it was not persisted to your store (it's in the ObjectsRemovedFromCollection property).
This link has more information about what is going on under the hood: MSDN
I'm not finding details about what explicitly triggers validation, but you can try calling AcceptChanges() or ObjectsAddedToCollectionProperties.Clear() and ObjectsRemovedFromCollectionProperties.Clear() before calling context.SubmitChanges()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With