Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Commented Issue: Can't set navigation property as required when using ODataConventionModelBuilder [472]

$
0
0
For example, I want to set one of the navigation property to be required:
public class Todo
{
public int Id { get; set; }
public Person CreatedBy { get; set; }
}
public class Person
{
public int PersonID { get; set; }
public string Name { get; set; }
}

var builder = new ODataConventionModelBuilder();
var todoes = builder.EntitySet<Todo>("Todo");
todoes.EntityType.HasRequired(t => t.CreatedBy);
return builder.GetEdmModel();

However, it reports following error:

System.ArgumentException occurred
HResult=-2147024809
Message=The multiplicity of the 'CreatedBy' property must be 'ZeroOrOne'.
Parameter name: navigationProperty
Source=System.Web.Http.OData
ParamName=navigationProperty
StackTrace:
at System.Web.Http.OData.Builder.EntityTypeConfiguration.AddNavigationProperty(PropertyInfo navigationProperty, EdmMultiplicity multiplicity) in C:\dd\DevDiv\Offcycle\WPT\WebStackRuntime\runtime\src\System.Web.Http.OData\OData\Builder\EntityTypeConfiguration.cs:line 226
InnerException:

Comments: http://aspnetwebstack.codeplex.com/SourceControl/changeset/41852a3a8fa8

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>