Executing the following two lines
DBContext.DbSet.Remove(DBContext.DbSet.First(x => x.Id == someExistingId));
DBContext.SaveChanges();
results in the following exception being thrown on SaveChanges()
when I override GetHashCode()
on the DbSet
entity type.
Adding a relationship with an entity which is in the Deleted state is not allowed.
I'm using a T4 Template to generate POCO objects and overriding GetHashCode()
in a partial
. If I comment out only the GetHashCode()
override, the code executes as expected.
The GetHashCode()
override just returns Id.GetHashCode()
. Id
is an int
.
Is there some restriction related to overriding GetHashCode()
with Entity Framework POCOs?
GetHashCode
and the related properties/methods that are used in computing the hash? I think I know what's going on but it's only a guess until I see the code.GetHashCode()
override just returnsId.GetHashCode()
. Was thinking about making it more complete but TBH I've not had to do more than that in the past.Id
?Id
is anint
Id
is mutable then it's not what I was thinking.