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
I recently migrated my project from .NET Core 3.1 to .NET 9.0. After the migration, I encountered an OData exception stating:
"Found more than one dynamic property container in type 'HttpRequestMessage'. Each open type must have at most one dynamic property container."
This issue did not occur in .NET Core 3.1 but appeared after moving to .NET 9.0 with AspNetCore.OData 9.1.3.
Here is my OData model builder setup:
varmodelBuilder=newODataConventionModelBuilder{Namespace="WebAPI",ContainerName="DefaultContainer"};// Attempt to exclude HttpRequestMessagemodelBuilder.ComplexType<HttpRequestMessage>().Ignore(hrm =>hrm.Properties);// Function definitionsmodelBuilder.Function("GetEntityData").Returns<Task<IActionResult>>().Parameter<string>("EntityName");modelBuilder.Function("AddEntityData").Returns<Task<IActionResult>>().Parameter<string>("EntityName");varputEntityData=modelBuilder.Function("UpdateEntityData").Returns<Task<IActionResult>>();putEntityData.Parameter<string>("EntityName");putEntityData.Parameter<Guid>("EntityId");vardeleteEntityData=modelBuilder.Function("DeleteEntityData").Returns<Task<IActionResult>>();deleteEntityData.Parameter<string>("EntityName");deleteEntityData.Parameter<Guid>("EntityId");
Full Exception Trace:
**System.ArgumentException: Found more than one dynamic property container in type 'HttpRequestMessage'.
Each open type must have at most one dynamic property container. (Parameter 'propertyInfo')
at Microsoft.OData.ModelBuilder.StructuralTypeConfiguration.AddDynamicPropertyDictionary(PropertyInfo propertyInfo)
at Microsoft.OData.ModelBuilder.ODataConventionModelBuilder.MapStructuralType(StructuralTypeConfiguration structuralType)
...
at Microsoft.AspNetCore.OData.Query.EnableQueryAttribute.OnActionExecuted(ActionExecutedContext actionExecutedContext)
at Microsoft.AspNetCore.Mvc.Filters.ActionFilterAttribute.OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
...
**
Request for Help
Is this a known issue in .NET 9 + OData 9.1.3?
-Are there new OData model validation rules causing this?
-What is the correct way to exclude HttpRequestMessage from OData mapping in .NET 9?
Would appreciate any insights or workarounds!
The text was updated successfully, but these errors were encountered:
I would expect us to consider a type with ambiguous object dictionary properties to be invalid and throw. This seems like we fixed a design issue we previously had.
I recently migrated my project from .NET Core 3.1 to .NET 9.0. After the migration, I encountered an OData exception stating:
"Found more than one dynamic property container in type 'HttpRequestMessage'. Each open type must have at most one dynamic property container."
This issue did not occur in .NET Core 3.1 but appeared after moving to .NET 9.0 with AspNetCore.OData 9.1.3.
Here is my OData model builder setup:
Full Exception Trace:
**System.ArgumentException: Found more than one dynamic property container in type 'HttpRequestMessage'.
Each open type must have at most one dynamic property container. (Parameter 'propertyInfo')
at Microsoft.OData.ModelBuilder.StructuralTypeConfiguration.AddDynamicPropertyDictionary(PropertyInfo propertyInfo)
at Microsoft.OData.ModelBuilder.ODataConventionModelBuilder.MapStructuralType(StructuralTypeConfiguration structuralType)
...
at Microsoft.AspNetCore.OData.Query.EnableQueryAttribute.OnActionExecuted(ActionExecutedContext actionExecutedContext)
at Microsoft.AspNetCore.Mvc.Filters.ActionFilterAttribute.OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
...
**
Request for Help
-Are there new OData model validation rules causing this?
-What is the correct way to exclude HttpRequestMessage from OData mapping in .NET 9?
Would appreciate any insights or workarounds!
The text was updated successfully, but these errors were encountered: