пилю на асп нет коре:
public class Client {
public int? ContactId { get; set; }
public virtual Contact Contact { get; set; }
public virtual ICollection<Contact> Contacts { get; set; }
}
| кидает исключение |
| The instance of entity type 'Contact' cannot be tracked because another instance with the same key value for {'Id'} is already being tracked. When attaching existing entities, ensure that only one entity instance with a given key value is attached. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see the conflicting key values. |
| |
Неужели ORM запрещает так делать?
Здравствуйте, varenikAA, Вы писали:
AA>пилю на асп нет коре:
AA>AA>public class Client {
AA> public int? ContactId { get; set; }
AA> public virtual Contact Contact { get; set; }
AA> public virtual ICollection<Contact> Contacts { get; set; }
AA>}
AA>
AA> | кидает исключение |
| AA>The instance of entity type 'Contact' cannot be tracked because another instance with the same key value for {'Id'} is already being tracked. When attaching existing entities, ensure that only one entity instance with a given key value is attached. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see the conflicting key values.
|
| |
AA>Неужели ORM запрещает так делать?
Что пытаетесь делать? Подозреваю, что пытаетесь добавить Сontact в model, при условии, что ICollection<Contact> уже
в находится в модели. Т.е. дважды пытаетесь добавить один и тот же контакт.