You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ODataTypeInfo.cs is identifying conventional Id properties using case sensitive checking on "ID" which is failing for POCO classes that use Id.
Assemblies affected
Microsoft.OData.Client
Reproduce steps
Create an OData Entity with a POCO that doesn't have [Key] attributes, but uses an "Id" property (Casing matters, ID will work, id, or Id, or god forbid iD will fail).
At runtime do a standard query against a DataServiceContext that is bound to the service.
Note that the entity is not tracked in the context.
Any attempt to track the entity will result in an exception indicating that the entity type is invalid as it does not define a key.
Defining an Edm manually, and ensuring the .HasKey() is called does not resolve the issue as it seems that the Edm is not used in this check.
Expected result
The entity would be tracked conventionally using the Id as the key as there are no other keys defined, and the entity is a valid entity type in the edm.
Actual result
An exception is thrown indicating that the entity is not a valid entity type.
Additional detail
The proposed fix is to change the check the property names using case insensitive comparison. I think a better fix would be to use the provided EDM to determine the nature of the EntityTypes as they are correct in the ClientEdmModel when configured using the fluent apis.
ODataTypeInfo.cs is identifying conventional Id properties using case sensitive checking on "ID" which is failing for POCO classes that use Id.
Assemblies affected
Microsoft.OData.Client
Reproduce steps
Create an OData Entity with a POCO that doesn't have [Key] attributes, but uses an "Id" property (Casing matters, ID will work, id, or Id, or god forbid iD will fail).
At runtime do a standard query against a DataServiceContext that is bound to the service.
Note that the entity is not tracked in the context.
Any attempt to track the entity will result in an exception indicating that the entity type is invalid as it does not define a key.
Defining an Edm manually, and ensuring the .HasKey() is called does not resolve the issue as it seems that the Edm is not used in this check.
Expected result
The entity would be tracked conventionally using the Id as the key as there are no other keys defined, and the entity is a valid entity type in the edm.
Actual result
An exception is thrown indicating that the entity is not a valid entity type.
Additional detail
The proposed fix is to change the check the property names using case insensitive comparison. I think a better fix would be to use the provided EDM to determine the nature of the EntityTypes as they are correct in the ClientEdmModel when configured using the fluent apis.
#3050
The text was updated successfully, but these errors were encountered: