خرید بک لینک

Vote count: 0

I have an entity with a child collection that I want to recreate on update.

My approach is just to clear entity.Items and regenerate collection, then I update try to update the entity on database.

Unfortunately I'm getting

The instance of entity type 'TestProject.Item' caot be tracked because another instance of this type with the same key is already being tracked. For new entities consider using an IIdentityGenerator to generate unique key values.

This error somehow make sense since I'm getting entity with child collection from databasebefore update it and then recreate it collection before saving with brand new instances.

What's the correct approach to recreate a collection with Entity Framework 7?

asked 24 secs ago

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 4 مرداد 1395 ساعت: 9:25

صفحه بندی