Permalink
Browse files

Issue 534: Error creating multiple entity sets for an entity type in

Conventional mb.

By design. Improving the error message being thrown to contain more
information with this commit.
  • Loading branch information...
1 parent 6b56870 commit 15e7a6101b011b6d9ed8ca940bdb818066b18fa3 raghuramn committed Nov 6, 2012
@@ -204,7 +204,11 @@ public NavigationPropertyBinding FindBinding(NavigationPropertyConfiguration nav
}
else
{
- throw Error.NotSupported(SRResources.CannotAutoCreateMultipleCandidates);
+ throw Error.NotSupported(
+ SRResources.CannotAutoCreateMultipleCandidates,
+ navigationConfiguration.Name,
+ navigationConfiguration.DeclaringEntityType.FullName,
+ String.Join(", ", matchingSets.Select(entitySet => entitySet.Name)));
}
}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -226,7 +226,7 @@
<value>The type '{0}' is not supported by the ODataErrorSerializer. The type must be ODataError or HttpError.</value>
</data>
<data name="CannotAutoCreateMultipleCandidates" xml:space="preserve">
- <value>Cannot autoCreate binding because there are two or more candidate EntitySets.</value>
+ <value>Cannot automatically bind the navigation property '{0}' on entity type '{1}' because there are two or more candidate entity sets. The matching entity sets are {2}.</value>
</data>
<data name="EntitySetHasNoBuildLinkAnnotation" xml:space="preserve">
<value>The entity set '{0}' is missing link generation configuration. Check that the self and edit links are configured during model building.</value>
@@ -227,5 +227,20 @@ public void CanConfigureLinks_For_NavigationPropertiesInDerivedType()
Assert.Equal("http://localhost/vehicles/2009/Motorcycle1/Manufacturer", link.AbsoluteUri);
}
+
+ [Fact]
+ public void CannotBindNavigationPropertyAutmatically_WhenMultipleEntitySetsOfPropertyType_Exist()
+ {
+ ODataModelBuilder builder = new ODataModelBuilder();
+ builder.EntitySet<Motorcycle>("motorcycles");
+ builder.EntitySet<MotorcycleManufacturer>("NorthWestMotorcycleManufacturers");
+ builder.EntitySet<MotorcycleManufacturer>("SouthWestMotorcycleManufacturers");
+ builder.Entity<Motorcycle>().HasRequired(m => m.Manufacturer);
+
+ Assert.Throws<NotSupportedException>(
+ () => builder.GetEdmModel(),
+ "Cannot automatically bind the navigation property 'Manufacturer' on entity type 'System.Web.Http.OData.Builder.TestModels.Motorcycle' because there are two or more candidate entity sets. " +
+ "The matching entity sets are NorthWestMotorcycleManufacturers, SouthWestMotorcycleManufacturers.");
+ }
}
}

0 comments on commit 15e7a61

Please sign in to comment.