I have the following annotated model
public class TypeA
{
public int TypeAId { get; set; }
[Required]
public TypeB B { get; set; }
public string AValue { get; set; }
}
public class TypeB
{
public int TypeBId { get; set; }
public string BValue { get; set; }
}
exposed as v3 odata by a WCF Data Service using entity framework. When i attempt to update a TypeA using a DataServiceContext such as
var ctx = new Service.Context(new Uri("http://localhost/TestUpdateService/TestUpdateService.svc"));
var t = ctx.theATypes.Expand(p => p.B).First();
t.AValue = "New value";
ctx.UpdateObject(t);
ctx.SaveChanges();
I get a DbEntityValidationException in the service stating "The B field is required"
the body of the request "MERGE /TestUpdateService/TestUpdateService.svc/theATypes(1) HTTP/1.1" contains the AValue property change but does not contain any of the link information to property B (which is my guess as to why the validation is failing in the service). Am i missing something about updating the data service?