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
Will work properly when we register both types and their keys manually:
ODataConventionModelBuilderbuilder= ...
Type typeToRegister =typeof(TestUser);
builder.AddEntityType(typeToRegister ).HasKey(typeToRegister.GetProperty("Id"))typeToRegister=typeof(TestRole);
builder.AddEntityType(typeToRegister ).HasKey(typeToRegister.GetProperty("Id"))
But it's not convenient to register all types from types hierarchy manually. In general we want to register only top hierarchy objects and provide registration of other types to the system.
And when we register only one type from that example:
The TestRole type is resolved as Complex type and not the Entity type, because it can not discover it's Key property.
Expected result
The Key property with private/protected set is discovered and type is considered as the Entity type.
Actual result
The Model builder skip all properties with private/protected set.
Additional detail
The Microsoft.OData.ModelBuilder.ConventionsHelpers.GetAllProperties method doesn't return property with private set. After that the Microsoft.OData.ModelBuilder.EntityKeyConvention.GetKeyProperty cannot discover key property.
The text was updated successfully, but these errors were encountered:
When we have the private set for the Key property. The EF works well with it Read-only properties. And we have all BO with private/proteced Key set.
Reproduce steps
The next classes set :
Will work properly when we register both types and their keys manually:
But it's not convenient to register all types from types hierarchy manually. In general we want to register only top hierarchy objects and provide registration of other types to the system.
And when we register only one type from that example:
The TestRole type is resolved as Complex type and not the Entity type, because it can not discover it's Key property.
Expected result
The Key property with private/protected set is discovered and type is considered as the Entity type.
Actual result
The Model builder skip all properties with private/protected set.
Additional detail
The Microsoft.OData.ModelBuilder.ConventionsHelpers.GetAllProperties method doesn't return property with private set. After that the Microsoft.OData.ModelBuilder.EntityKeyConvention.GetKeyProperty cannot discover key property.
The text was updated successfully, but these errors were encountered: