private static void SetFakeKeyValues(object entity, EntityType entityType) { foreach (EdmProperty keyProperty in entityType.KeyProperties) { PropertyInfo clrPropertyInfo = keyProperty.GetClrPropertyInfo(); object fakeKeyValue = ModificationCommandTreeGenerator.GetFakeKeyValue(keyProperty.UnderlyingPrimitiveType.PrimitiveTypeKind); clrPropertyInfo.GetPropertyInfoForSet().SetValue(entity, fakeKeyValue, (object[])null); } }