When Overriding GetHashCode(), Entity Framework 6 Throws Exception on SaveChanges()

c# entity-framework entity-framework-6

Question

Putting the next two lines into action

DBContext.DbSet.Remove(DBContext.DbSet.First(x => x.Id == someExistingId));
DBContext.SaveChanges();

leads in the throwing of the following exception onSaveChanges() when I interveneGetHashCode() on theDbSet entity class.

Adding a relationship with an entity which is in the Deleted state is not allowed.

To create POCO objects, I'm overriding a T4 Template.GetHashCode() in apartial If I leave out only theGetHashCode() override, the programme runs as intended.

The GetHashCode() just override returnsId.GetHashCode() . Id is anint .

Exists a limitation in relation to overriding?GetHashCode() with POCOs for Entity Framework?

1
1
9/7/2017 12:27:26 AM

Accepted Answer

ZZZ_tmp
1
9/7/2017 1:05:07 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow