Last post Jun 01, 2015 01:07 PM by dtotzke
Nov 12, 2014 05:51 AM|ksureshh_pk|LINK
I have a product and category entities, and it has many to many relationship. So while creating the product, I will pass the list of categories in which product get mapped to it. But while creating the product , product alone creating and mapping is not
creating. below is the example.
var container = new Service.Container(new Uri(serviceBusUri));
Service.Products objProducts = new Service.Products();
objProducts.ProductName = "nokias";
objProducts.CreatedOn = DateTime.Now;
objProducts.CreatedBy = "suresh";
Service.Category objCategory=new Servi.Category();
objCategory= container.Categories.Where(c => c.ID == 36299).SingleOrDefault();
container.AddToProducts(objProducts); var response = container.SaveChanges();
Can anyone give me idea why product is not mapping to the category?
Nov 13, 2014 02:40 AM|Shawn - MSFT|LINK
For this situation, it seems that the issue is more realted to the Entity Framework, however, this forum is focus on the web api issue. And you could post the issue to the Entity Framework Forum for further help:
Nov 16, 2014 11:31 PM|ksureshh_pk|LINK
While working separately with the entity framework, the above scenario is working fine without any issues. but while using it with web api, its not working.
from client am assigning the value to the collection property of entity like below.
in the odata service post method, while checking the entity collection, its coming as null.. ie if you check the product.categories in the below method.
public IHttpActionResult Post(Products product)
I feel like it seems to be an issue with web api on passing the inputs in the post request and its not related to entity framework.
Please correct me if am wrong.
Jun 01, 2015 01:07 PM|dtotzke|LINK
Did you ever find a resolution to this problem? I am having the same issue with WebApi 2.2 and OData v4 with EF6. Very frustrating.