Scenario:
I have defined an entity set with a custom edit link (that doesn't follows conventions) and when I try to retrieve an entity in minimal metadata mode to check that the edit link gets emitted, I get a null reference exception.
Request:
GET http://localhost:10000/CustomConventions/StubEntity(1) HTTP/1.1
Host: localhost:10000
Connection: Keep-Alive
Exception detail:
System.ArgumentNullException occurred
HResult=-2147467261
Message=Value cannot be null.
Parameter name: uriString
Source=System
ParamName=uriString
StackTrace:
at System.Uri..ctor(String uriString)
at System.Web.Http.OData.Builder.EntitySetLinkBuilderAnnotation.BuildEditLink(EntityInstanceContext instanceContext, ODataMetadataLevel metadataLevel, String idLink) in c:\work\aspnetwebstack\src\System.Web.Http.OData\OData\Builder\EntitySetLinkBuilderAnnotation.cs:line 118
InnerException:
Metadata document:
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
<edmx:DataServices m:DataServiceVersion="3.0" m:MaxDataServiceVersion="3.0" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<Schema Namespace="CustomConventionsLinkRepro.Models" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
<EntityType Name="StubEntity">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Name="Id" Type="Edm.Int32" Nullable="false" />
</EntityType>
</Schema>
<Schema Namespace="Default" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
<EntityContainer Name="Container" m:IsDefaultEntityContainer="true">
<EntitySet Name="StubEntity" EntityType="CustomConventionsLinkRepro.Models.StubEntity" />
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
Repro steps:
1) Open the attached project as administrator.
2) Point the System.Web.Odata.dll reference to the location of your dll.
3) Enable break on thown exceptions.
4) Run the project.
I have defined an entity set with a custom edit link (that doesn't follows conventions) and when I try to retrieve an entity in minimal metadata mode to check that the edit link gets emitted, I get a null reference exception.
Request:
GET http://localhost:10000/CustomConventions/StubEntity(1) HTTP/1.1
Host: localhost:10000
Connection: Keep-Alive
Exception detail:
System.ArgumentNullException occurred
HResult=-2147467261
Message=Value cannot be null.
Parameter name: uriString
Source=System
ParamName=uriString
StackTrace:
at System.Uri..ctor(String uriString)
at System.Web.Http.OData.Builder.EntitySetLinkBuilderAnnotation.BuildEditLink(EntityInstanceContext instanceContext, ODataMetadataLevel metadataLevel, String idLink) in c:\work\aspnetwebstack\src\System.Web.Http.OData\OData\Builder\EntitySetLinkBuilderAnnotation.cs:line 118
InnerException:
Metadata document:
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
<edmx:DataServices m:DataServiceVersion="3.0" m:MaxDataServiceVersion="3.0" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<Schema Namespace="CustomConventionsLinkRepro.Models" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
<EntityType Name="StubEntity">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Name="Id" Type="Edm.Int32" Nullable="false" />
</EntityType>
</Schema>
<Schema Namespace="Default" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
<EntityContainer Name="Container" m:IsDefaultEntityContainer="true">
<EntitySet Name="StubEntity" EntityType="CustomConventionsLinkRepro.Models.StubEntity" />
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
Repro steps:
1) Open the attached project as administrator.
2) Point the System.Web.Odata.dll reference to the location of your dll.
3) Enable break on thown exceptions.
4) Run the project.