Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
KeyFieldIsUniqueInCollectionConstraint fails when loading a new object #88
KeyFieldIsUniqueInCollectionConstraint fails for a new object because @@IDENTITY returns a DECIMAL and there is an equality test with the value from the database for usually an INT field. Therefore (DECIMAL)1 and INT(1) are not considered equal and the constraint incorrectly fails.
This does not affect situations where the object is reloaded and then saved because the DistinctValue will be of the correct INT type.