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
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