Using OData v4 in .Net, I have two classes and can't seem to get the entity relationship between them to be stored in the DB.
public class Customer
{
int Id {get;set;}
...
}
public class Order
{
int Id {get;set;}
public virtual Customer customer {get;set;}
...
}
WebApiConfig.cs
builder.EntitySet<Order>("Orders");
builder.EntityType<Order>().ContainsRequired(o => o.Customer);
builder.EntitySet<Customer>("Customers";
And my inline code looks like:
var cust = new Customer(...);
var order = new Order(...);
container.AddToOrders(order);
container.SetLink(order,"Customer", cust);
container.SaveChanges();
I don't get any errors, but when I debug the controllers, the customer object in the order object is null. If, in the controller, i reset the customer object in the order object, the data gets stored correctly. So it appears that the entity framework portion is working correctly, just can't get the OData client to serialize the inbound Customer object in the Order object.
Any help on what I am missing (from the client side) would be greatly appreciated.
Thanks.